Here you can find the source of getHMSFromMills(long millSec)
public static String getHMSFromMills(long millSec)
//package com.java2s; /*// w w w . j a va 2 s . c o m * License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt */ import java.text.DecimalFormat; public class Main { public static String getHMSFromMills(long millSec) { String retval; int decimal = (int) (millSec % 1000); int seconds = (int) (millSec / 1000); if (seconds > 0) { if (seconds < 60) { retval = seconds + "." + decimal + " sec"; } else { String outStr = getHMS(seconds); retval = outStr + "." + decimal; } } else { retval = decimal + " ms"; } return retval; } /** * Get a String in HH:MM:SS format for a gievn total seconds (float) * total seconds = hour*3600 + minute*60 +seconds, Michael Nguyen * @param totalSecond of seconds * @return String */ public static String getHMS(int totalSecond) { return getHMS((long) totalSecond); } /** * Get a String in HH:MM:SS format for a gievn total seconds (float) * total seconds = hour*3600 + minute*60 +seconds, Michael Nguyen * @param totalSecond of seconds * @return String */ public static String getHMS(long totalSecond) { String time = "00:00:00"; DecimalFormat decimalFormat = new DecimalFormat("00"); if (totalSecond > 0) { long hour = totalSecond / 3600; if (hour > 0) time = decimalFormat.format(hour); else time = "00"; time += ":"; long minute = (totalSecond - (hour * 3600)) / 60; if (minute > 0) time += decimalFormat.format(minute); else time += "00"; time += ":"; long second = totalSecond - (hour * 3600) - (minute * 60); if (second > 0) time += decimalFormat.format(second); else time += "00"; return time; } else return time; } }