com.rt.storage.api.client.util.Clock Maven / Gradle / Ivy
package com.rt.storage.api.client.util;
/**
* Clock which can be used to get the amount of elapsed milliseconds in system time.
*
* The default system implementation can be accessed at {@link #SYSTEM}. Alternative
* implementations may be used for testing.
*
* @since 1.9
*/
public interface Clock {
/**
* Returns the current time in milliseconds since midnight, January 1, 1970 UTC, to match the
* behavior of {@link System#currentTimeMillis()}.
*/
long currentTimeMillis();
/**
* Provides the default System implementation of a Clock by using {@link
* System#currentTimeMillis()}.
*/
Clock SYSTEM =
new Clock() {
public long currentTimeMillis() {
return System.currentTimeMillis();
}
};
}