Here you can find the source of milliSecondsToTimer(long milliseconds)
public static String milliSecondsToTimer(long milliseconds)
//package com.java2s; public class Main { public static String milliSecondsToTimer(long milliseconds) { String totalTime = ""; String totalSeconds = ""; String totalMinutes = ""; int hours = (int) (milliseconds / (1000 * 60 * 60)); int minutes = (int) (milliseconds % (1000 * 60 * 60)) / (1000 * 60); int seconds = (int) ((milliseconds % (1000 * 60 * 60)) % (1000 * 60) / 1000);// w ww.ja va 2s. c o m if (hours > 0) { if (hours < 10) { totalTime = "0" + hours + ":"; } else { totalTime = hours + ":"; } } // Prepending 0 to seconds if it is one digit if (seconds < 10) { totalSeconds = "0" + seconds; } else { totalSeconds = "" + seconds; } if (minutes < 10) { totalMinutes = "0" + minutes; } else { totalMinutes = "" + minutes; } totalTime = totalTime + totalMinutes + ":" + totalSeconds; // return timer string return totalTime; } }