-
-
Save vincenthauser/4fc9cff06163aa9fc019c26e6be4a097 to your computer and use it in GitHub Desktop.
Formatted Milliseconds
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 static String msToString(long ms) { | |
long totalSecs = ms/1000; | |
long hours = (totalSecs / 3600); | |
long mins = (totalSecs / 60) % 60; | |
long secs = totalSecs % 60; | |
String hrsString = (hours == 0) | |
? "00" | |
: ((hours < 10) | |
? "0" + hours | |
: "" + hours); | |
String minsString = (mins == 0) | |
? "00" | |
: ((mins < 10) | |
? "0" + mins | |
: "" + mins); | |
String secsString = (secs == 0) | |
? "00" | |
: ((secs < 10) | |
? "0" + secs | |
: "" + secs); | |
//if (hours > 0) | |
return hrsString + ":" + minsString + ":" + secsString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment