Java TimeUnit Usage currentMillisFromNanotime()

Here you can find the source of currentMillisFromNanotime()

Description

System#nanoTime() is less expensive than System#currentTimeMillis() and better suited to measure time intervals.

License

Apache License

Return

the value of , but converted in Milliseconds.

Declaration

public static final long currentMillisFromNanotime() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.concurrent.TimeUnit;

public class Main {
    /**//  w w w  .  j  av  a 2  s.  c  om
     * {@link System#nanoTime()} is less expensive than {@link System#currentTimeMillis()} and better suited
     * to measure time intervals. It's NOT suited to know the current time, for example to be compared
     * with the time of other nodes.
     * @return the value of {@link System#nanoTime()}, but converted in Milliseconds.
     */
    public static final long currentMillisFromNanotime() {
        return TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
    }
}

Related

  1. convertMillisecondsToHHMMSS(long milliseconds)
  2. convertNanosecondTimespanToHumanReadableFormat(long aTimespan, boolean aShortFormat, boolean aLongFormat)
  3. convertNanoToSeconds(long nanoTime)
  4. createTimeString(int year, int month, int day, int hours, int minutes, int seconds, String timezoneID)
  5. createTimezoneString(String timezoneID)
  6. dateDiff(Date d1, Date d2)
  7. dateStart(final Calendar c)
  8. daysBetween(Calendar startDate, Calendar endDate)
  9. daysBetween(Date initDate, Date endDate)