Here you can find the source of milisecondsToMinutesAndSeconds(int milliseconds)
public static String milisecondsToMinutesAndSeconds(int milliseconds)
//package com.java2s; public class Main { public static String milisecondsToMinutesAndSeconds(int milliseconds) { int seconds = (int) (milliseconds / 1000) % 60; int minutes = (int) ((milliseconds / (1000 * 60)) % 60); int hours = (int) ((milliseconds / (1000 * 60 * 60)) % 24); StringBuffer buffer = new StringBuffer(); String prefix = ""; if (hours > 0) { prefix = hours < 10 ? "0" : ""; buffer.append(prefix + hours + ":"); }/*from ww w . j a v a2 s . c o m*/ prefix = minutes < 10 ? "0" : ""; buffer.append(prefix + minutes + ":"); prefix = seconds < 10 ? "0" : ""; buffer.append(prefix + seconds); return buffer.toString(); } }