Here you can find the source of formatTime(String time)
public static String formatTime(String time)
//package com.java2s; // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt public class Main { private final static String SPACE = " "; private final static String MILLISECOND = "ms"; private final static String SECOND = "s"; private final static String MINUTE = "m"; public static String formatTime(String time) { Long time_ms = 0L;/*from ww w . j a va2 s. c o m*/ try { time_ms = Long.parseLong(time); } catch (NumberFormatException nfe) { // nfe.printStackTrace(); return ""; //$NON-NLS-1$ } if (time_ms < 1000) { return time_ms + MILLISECOND; } else { Long time_s = time_ms / 1000; Long time_s_ms = time_ms % 1000; if (time_s < 60) { StringBuilder sb = new StringBuilder(); sb.append(time_s + SECOND); if (time_s_ms != 0) { sb.append(SPACE + time_s_ms + MILLISECOND); } return sb.toString(); } else { Long time_m = time_s / 60; Long time_m_s = time_s % 60; StringBuilder sb = new StringBuilder(); sb.append(time_m + MINUTE); if (time_m_s != 0) { sb.append(SPACE + time_m_s + SECOND); } if (time_s_ms != 0) { sb.append(SPACE + time_s_ms + MILLISECOND); } return sb.toString(); } } } }