Here you can find the source of stringTime(long time)
Parameter | Description |
---|---|
time | a parameter |
public static String stringTime(long time)
//package com.java2s; import java.text.DecimalFormat; public class Main { /**/*from w ww . ja va2 s.co m*/ * PURPOSE: <br> * stringTime<br> * <br> * * @param time * @return<br> */ public static String stringTime(long time) { DecimalFormat twoDigitIntFormat = new DecimalFormat("00"); DecimalFormat threeDigitIntFormat = new DecimalFormat("000"); int hrs = (int) (time / (1000 * 60 * 60)); int mins = (int) ((time % (1000 * 60 * 60)) / (1000 * 60)); int sec = (int) (((time % (1000 * 60 * 60)) % (1000 * 60)) / 1000); int millis = (int) (time % 1000); return String.format("%s:%s:%s.%s", twoDigitIntFormat.format(hrs), twoDigitIntFormat.format(mins), twoDigitIntFormat.format(sec), threeDigitIntFormat.format(millis)); } }