Here you can find the source of millisecondsToHHMMSS(long milliseconds)
public static String millisecondsToHHMMSS(long milliseconds)
//package com.java2s; public class Main { /**/*from w w w .ja v a 2 s . c om*/ * Convert a time in milliseconds to "hh:mm:ss" format. */ public static String millisecondsToHHMMSS(long milliseconds) { // convert from fraction of day to milliseconds long total = (milliseconds / 1000); long hours = total / 3600; total = total - (hours * 3600); long minutes = total / 60; total = total - (minutes * 60); long seconds = total; String sHours = hours + ""; String sMinutes = minutes + ""; String sSeconds = seconds + ""; if (hours < 1) { sHours = "00"; } else if (hours < 10) { sHours = "0" + sHours; } if (minutes < 1) { sMinutes = "00"; } else if (minutes < 10) { sMinutes = "0" + sMinutes; } if (seconds < 1) { sSeconds = "00"; } else if (seconds < 10) { sSeconds = "0" + sSeconds; } return sHours + ":" + sMinutes + ":" + sSeconds; } }