Skip to content

Instantly share code, notes, and snippets.

@vuhung3990
Last active February 13, 2017 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vuhung3990/cdc2b6cf3aae43db5d1e to your computer and use it in GitHub Desktop.
Save vuhung3990/cdc2b6cf3aae43db5d1e to your computer and use it in GitHub Desktop.
convert unix time to hh:MM:ss
/**
* 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