Java Long Number to Time getTimeString(long nanoTime)

Here you can find the source of getTimeString(long nanoTime)

Description

Get a human readable String of the given time-period.

License

Open Source License

Parameter

Parameter Description
nanoTime time-period

Return

human readable String

Declaration

public static String getTimeString(long nanoTime) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.NumberFormat;
import java.util.Locale;

public class Main {
    /**/* w w w .  j a v a 2s.com*/
     * Get a human readable String of the given time-period.
     *
     * @param nanoTime time-period
     * @return human readable String
     */
    public static String getTimeString(long nanoTime) {
        NumberFormat nf = NumberFormat.getInstance(Locale.GERMANY);
        float time = nanoTime;
        time /= 1000000;
        String result = nf.format(time) + " ms";
        if (time >= 1000) {
            time /= 1000;
            result += " (" + nf.format(time) + " sec)";
        }

        return result;
    }
}

Related

  1. getTimeOf12(long time)
  2. getTimeOld(long time)
  3. getTimestampDiff(Long old)
  4. getTimeStr(long t)
  5. getTimeStr(long timeLong)
  6. getTimeString(long time)
  7. getTimeTagged(long time, boolean round)
  8. getTimeText(Long oldTime)
  9. getUploadPath(String fileName, long time)