Android examples for java.util:Date Time
Format time for hour:minute:second
public class Main { public static String getTotalVideoTimeFormat(long videoTotalTime) { int totalSeconds = (int) (videoTotalTime / 1000L); int seconds = totalSeconds % 60; int minutes = (totalSeconds / 60) % 60; int hours = totalSeconds / 3600; return (hours > 0 ? String.format("%02d:%02d:%02d", new Object[] { Integer.valueOf(hours), Integer.valueOf(minutes), Integer.valueOf(seconds) }) : String.format("%02d:%02d", new Object[] { Integer.valueOf(minutes), Integer.valueOf(seconds) })); }//from w w w. j ava 2 s . c o m }