Java tutorial
import java.util.concurrent.TimeUnit; public class Main { public static void main(String[] argv) { System.out.println(millisToString(100000000)); } public static String millisToString(long millis) { long hours = TimeUnit.MILLISECONDS.toHours(millis); long minutes = TimeUnit.MILLISECONDS.toMinutes(millis) - (hours * 60); long seconds = TimeUnit.MILLISECONDS.toSeconds(millis) - ((hours * 60 * 60) + (minutes * 60)); millis = millis - ((hours * 60 * 60 * 1000) + (minutes * 60 * 1000) + (seconds * 1000)); return String.format("%d hr(s) %d min(s) %d sec(s) %d ms", hours, minutes, seconds, millis); } }