Here you can find the source of formatTime(long time)
public static String formatTime(long time)
//package com.java2s; public class Main { public static final long SECONDS_IN_MILLIS = 1000L; public static final long MINUTE_IN_MILLIS = 60 * SECONDS_IN_MILLIS; public static final String SECONDS = " seconds"; private static final String MILLIS = " ms"; public static String formatTime(long time) { if (time > MINUTE_IN_MILLIS) { return formatMinutes(time); }/* w w w.ja va 2 s. co m*/ if (time > SECONDS_IN_MILLIS) { return formatSeconds(time); } else { return formatMillis(time); } } private static String formatMinutes(long time) { //todo - implement this method. return formatSeconds(time); } private static String formatSeconds(long time) { long kbsize = Math.round((float) time / SECONDS_IN_MILLIS); //format 0 decimal places return String.valueOf(kbsize) + SECONDS; } private static String formatMillis(long time) { return time + MILLIS; } }