Forked from vuhung3990/convert unix time to hh:MM:ss.java
Created
February 13, 2017 08:53
-
-
Save ar-android/75e0a50a4af55183f8ebdcfe851e054a to your computer and use it in GitHub Desktop.
convert unix time to hh:MM:ss
This file contains 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
/** | |
* convert milisec to hh:MM:ss | |
* @param millisUntilFinished | |
* @return String time | |
*/ | |
public static String convertMilisecToHMmSs(long millisUntilFinished) { | |
return String.format("%02d:%02d:%02d", | |
TimeUnit.MILLISECONDS.toHours(millisUntilFinished), | |
TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) - TimeUnit.HOURS.toMinutes( | |
TimeUnit.MILLISECONDS.toHours(millisUntilFinished)), | |
TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds( | |
TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment