Here you can find the source of printTimeString(long time)
public static String printTimeString(long time)
//package com.java2s; import java.util.concurrent.TimeUnit; public class Main { public static String printTimeString(long time) { TimeUnit timeUnit = TimeUnit.MILLISECONDS; long diffSec = timeUnit.toSeconds(time); long diffMin = timeUnit.toMinutes(time); StringBuilder sb = new StringBuilder(); sb.append(time).append(" ms"); if (diffMin >= 1) { sb.append("(").append(diffMin).append("m").append(" ") .append(diffSec - TimeUnit.MINUTES.toSeconds(diffMin)).append("s").append(")"); } else if (diffSec >= 1) { sb.append("(").append(diffSec).append("s").append(")"); }// w w w . ja v a2 s . co m return sb.toString(); } }