List of utility methods to do Nano Second Convert
long | nanosecondsToSeconds(long nanoseconds) nanoseconds To Seconds return (long) (nanoseconds / NANOS_PER_SECOND); |
String | nanosecondsToString(long ns) Format a long representing nanoseconds into a string of the form "[seconds].[nanoseconds]" with the appropriate zero-padding. ns = Math.abs(ns); String time = Long.toString(ns); int length = time.length(); if (time.length() > 9) { time = time.substring(0, length - 9) + "." + time.substring(length - 9); return time; for (int i = length; i < 9; i++) { ... |
double | nanoSecondToSecond(double nano, int decimal) Convert from nano second to second double precision = Math.pow(10, decimal); double second = nano / 1_000_000_000d; return Math.round(second * precision) / precision; |
String | nanoSecToString(final long nS) Returns the given time in nanoseconds formatted as Sec.mSec uSec nSec final long rem_nS = (long) (nS % 1000.0); final long rem_uS = (long) ((nS / 1000.0) % 1000.0); final long rem_mS = (long) ((nS / 1000000.0) % 1000.0); final long sec = (long) (nS / 1000000000.0); final String nSstr = zeroPad(Long.toString(rem_nS), 3); final String uSstr = zeroPad(Long.toString(rem_uS), 3); final String mSstr = zeroPad(Long.toString(rem_mS), 3); return String.format("%d.%3s %3s %3s", sec, mSstr, uSstr, nSstr); ... |
int | nanosForFractionalValue(int value, int width) nanos For Fractional Value switch (width) { case 0: return 0; case 1: return value * 10000000; case 2: return value * 100000; case 3: ... |
long | nanoTime() Equivalent to System.nanoTime(), but based off the 1/1/1970 epoch like currentTimeMillis(). return System.nanoTime() + nanoTimeOffset;
|
long | nanoTime() nano Time return System.nanoTime();
|
boolean | nanoTimeLessThan(long leftNanos, long rightNanos) Compare two nanosecond times. return ((leftNanos - rightNanos) < 0L);
|
double | nanoTimeToSeconds(long nanoTime) nano Time To Seconds return nanoTime / 1000000000.0;
|
float | nanoToMilli(double nanoseconds) nano To Milli return (float) nanoseconds / 1000 / 1000; |