Java Long Number to Time stringTime(long time)

Here you can find the source of stringTime(long time)

Description

PURPOSE:
stringTime

License

Open Source License

Parameter

Parameter Description
time a parameter

Return


Declaration

public static String stringTime(long time) 

Method Source Code


//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));
    }
}

Related

  1. longToTimedDate(long time)
  2. prettyDate(long time)
  3. printDuration(String message, long startTime)
  4. printExecutionTime(long startTime, long endTime, String className, String methodName)
  5. str2Long(String time)
  6. stringTolong(String time)
  7. time2Date(Long time)
  8. time2DATETIME(long time)
  9. toLong(String time)