Here you can find the source of millisToHMSms(long millis)
public static String millisToHMSms(long millis)
//package com.java2s; import java.util.concurrent.TimeUnit; public class Main { public static String millisToHMSms(long millis) { long hour = TimeUnit.MILLISECONDS.toHours(millis); long in1 = millis - TimeUnit.HOURS.toMillis(hour); long minute = TimeUnit.MILLISECONDS.toMinutes(in1); long in2 = in1 - TimeUnit.MINUTES.toMillis(minute); long second = TimeUnit.MILLISECONDS.toSeconds(in2); long in3 = in2 - TimeUnit.SECONDS.toMillis(second); return String.format("%dh:%dm:%ds:%dms", hour, minute, second, in3); }//from w ww .j av a2 s. c om }