Elapsed time in hours/minutes/seconds
public class Util{
/**
* elapsed time in hours/minutes/seconds
* @return String
*/
public static String getElapsedTimeHoursMinutesFromMilliseconds(long milliseconds) {
String format = String.format("%%0%dd", 2);
long elapsedTime = milliseconds / 1000;
String seconds = String.format(format, elapsedTime % 60);
String minutes = String.format(format, (elapsedTime % 3600) / 60);
String hours = String.format(format, elapsedTime / 3600);
String time = hours + ":" + minutes + ":" + seconds;
return time;
}
}
Related examples in the same category