Here you can find the source of getHourMinuteSecond(long misSecond)
public static String getHourMinuteSecond(long misSecond)
//package com.java2s; public class Main { public static String getHourMinuteSecond(long misSecond) { if (misSecond < 0) { throw new IllegalArgumentException("The misSecond must not be negative"); }/*w ww . jav a 2 s . c om*/ long second = misSecond / 1000; long hour = second / 3600; long minute = (second % 3600) / 60; long sec = second % 3600 % 60; String hourStr = String.valueOf(hour); String minuteStr = String.valueOf(minute); String secStr = String.valueOf(sec); hourStr = extendTimeZeroChars(hourStr, 2); minuteStr = extendTimeZeroChars(minuteStr, 2); secStr = extendTimeZeroChars(secStr, 2); return hourStr + ":" + minuteStr + ":" + secStr; } private static String extendTimeZeroChars(String str, int len) { String s = str; if (str.length() >= len) { return str; } else { for (int i = 0; i < (len - str.length()); i++) { s = "0" + s; } return s; } } }