
com.wavefront.common.Clock Maven / Gradle / Ivy
package com.wavefront.common;
/**
* Clock to manage agent time synced with the server.
*
* @author Clement Pang ([email protected]).
*/
public abstract class Clock {
private static Long serverTime;
private static Long localTime;
public static void set(long serverTime) {
localTime = System.currentTimeMillis();
Clock.serverTime = serverTime;
}
public static long now() {
if (serverTime == null) return System.currentTimeMillis();
else return (System.currentTimeMillis() - localTime) + serverTime;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy