Here you can find the source of formatMs(long millis)
public static String formatMs(long millis)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.TimeUnit; public class Main { public static String formatMs(long millis) { return String.format("%02d:%02d:%02d.%03d", TimeUnit.MILLISECONDS.toHours(millis), TimeUnit.MILLISECONDS.toMinutes(millis) % TimeUnit.HOURS.toMinutes(1), TimeUnit.MILLISECONDS.toSeconds(millis) % TimeUnit.MINUTES.toSeconds(1), millis % 1000); }//from w w w. ja v a2 s. co m }