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;
}
}
Home
Java Book
Runnable examples
Java Book
Runnable examples
Date Convert:
- Convert Calendar to java.sql.Date
- Convert day of year to day of month
- Convert java.util.Date to java.sql.Time after calculation
- Convert java.util.Date to java.sql.Date after calculation
- Convert java.util.Date to java.sql.Date
- Convert Date into milliseconds
- Convert date to GMT
- Convert day of the year to date
- Convert milliseconds to readable string
- Elapsed time in hours/minutes/seconds
- Convert longs (time_t in UNIX terminology) to seconds