Clock implementation that creates an anchor between the time sources used by System.nanoTime
and
System.currentTimeMillis
to create Instant instances that properly reflect the current system time (as is always
the case with System.currentTimeMillis
) but with better performance characteristics, given that the current
Instant can be derived using a call to System.nanoTime
, which is considerably faster.
Returns the number of nanoseconds between two instants.
Returns the next Instant that aligns with the provided bucket size duration.
Returns the next Instant that aligns with the provided bucket size duration. For example, if this function is called with an instant of 11:34:02 AM and a bucket size of 20 seconds, the returned Instant will be 11:34:20 AM, which is the next Instant that perfectly aligns with 20 second bucket boundaries from the EPOCH.
Returns the number of microseconds between the EPOCH and the provided instant.