All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gridkit.nimble.probe.jmx.threading.TimeUtils Maven / Gradle / Ivy

package org.gridkit.nimble.probe.jmx.threading;

import java.util.concurrent.TimeUnit;

class TimeUtils {
	
	private static double S = TimeUnit.SECONDS.toNanos(1);
	private static double N = TimeUnit.MILLISECONDS.toNanos(1);
	
	private static long NANO_ANCHOR = System.nanoTime();
	private static double MILLIS_ANCHOR = N * System.currentTimeMillis();
	
	public static double normalize(long nanotime) {
		return (MILLIS_ANCHOR + (nanotime - NANO_ANCHOR)) / S;
	}
	
	public static long toMillis(double epoc) {
		return (long)(1000 * epoc);
	}

	public static double toSeconds(double nanos) {
		return nanos / S;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy