Created
July 13, 2016 15:29
-
-
Save gen0083/cbf0ce046b0451fc91d17081d88a809a to your computer and use it in GitHub Desktop.
Convert milliseconds to String format with "00:00:00"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TimeUtil { | |
public static String humanReadableTimeWith(long millis) { | |
final long hour = TimeUnit.MILLISECONDS.toHours(millis); | |
final long minute = TimeUnit.MILLISECONDS.toMinutes(millis) - | |
TimeUnit.HOURS.toMinutes(hour); | |
final long second = TimeUnit.MILLISECONDS.toSeconds(millis) - | |
TimeUnit.MINUTES.toSeconds(minute) - | |
TimeUnit.HOURS.toSeconds(hour); | |
return String.format("%02d:%02d:%02d", hour, minute, second); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment