ExactTime

public final class ExactTime

Utility class to access the underlying system clock with improved precision compared to the standard Java library capabilities. Various native methods are probed for accessing the time source. If none of them works, this class falls back to System.currentTimeMillis(), resulting in a reduced precision of the returned time.

Author

jwienke

Methods

currentTimeMicros

public static long currentTimeMicros()

Returns the current system time in microsecond precision using best effort. In case no available native implementation provides this resolution, a reduced one is returned. Check isFallback() to get information on this case.

Returns

Unix timestamp for the system time in microseconds

isFallback

public static boolean isFallback()

In case no implementation is known that provides accurate time information for the underlying platform, this method returns true.

Returns

true if no accurate time can be provided.