Here you can find the source of getDuration(long time)
public static String getDuration(long time)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; public class Main { public static String getDuration(long time) { NumberFormat f = NumberFormat.getInstance(); f.setMinimumIntegerDigits(2);// w ww .j a v a2 s. co m int milliseconds = (int) (time % 1000); time /= 1000; int seconds = (int) time % 60; time /= 60; int minutes = (int) time % 60; time /= 60; int hours = (int) time; String result = f.format(hours) + ":" + f.format(minutes) + ":" + f.format(seconds); f.setMinimumIntegerDigits(3); result += ":" + f.format(milliseconds); return result; } }