List of utility methods to do Nano Second Convert
void | appendSecondsToDurationString(final StringBuilder sb, final long seconds, final long nanoseconds) append Seconds To Duration String if (seconds < 0 && nanoseconds > 0) { if (seconds == -1) { sb.append("0"); } else { sb.append(Math.abs(seconds + 1)); } else { sb.append(Math.abs(seconds)); ... |
long | asNanoSeconds(long seconds) as Nano Seconds return (seconds * 1000 + MICROSECONDS_TO_UNIX_EPOCH_FROM_WINDOWS) * 10;
|
long | doubleToNanoseconds(double d) double To Nanoseconds return (long) (d * 1000000000); |
float | durationInSeconds(long startNano) Returns the duration in second between the specified nano time and now. final long endNano = System.nanoTime(); final long durationMillis = (endNano - startNano) / 1000000; final float duration = durationMillis / 1000f; return duration; |
String | humanReadableNanoseconds(long delta) human Readable Nanoseconds if (delta < 10L * 1000) { return delta + " nanoseconds"; } else if (delta < 10L * 1000 * 1000) { return delta / 1000 + " microseconds"; } else if (delta < 10L * 1000 * 1000 * 1000) { return delta / (1000 * 1000) + " milliseconds"; } else { return delta / (1000 * 1000 * 1000) + " seconds"; ... |
String | microSecondToStr(int nanos, int meta) micro Second To Str if (meta > 6) { throw new IllegalArgumentException("unknow useconds meta : " + meta); String microSecond = ""; if (meta > 0) { microSecond = String.valueOf(nanos); if (microSecond.length() < meta) { int total = meta % 2 == 0 ? meta : meta + 1; ... |
long | nano() Get the current time in nano second. return System.nanoTime();
|
double | nano2milli(double nano) Translate from nano (10^-9) to milli (10^-3). return nano * 1e-6;
|
long | nanoSeconds(long millis) nano Seconds return millis * 1000000;
|
long | nanoSecondsToSeconds(final long nanoSeconds) Reduces nanosecond time to seconds. return nanoSeconds / NANO_TIME_DIVIDER;
|