public enum ClockWithOffset extends java.lang.Enum<ClockWithOffset> implements Clock
Clock
that provides a way to modify the time returned by
System.currentTimeMillis()
.
This can be used during application shutdown to force the clock forward and get the
latest values which normally
would not be returned until the next step boundary is crossed.Enum Constant and Description |
---|
INSTANCE
Singleton.
|
Modifier and Type | Method and Description |
---|---|
long |
now()
Returns the number of milliseconds since the epoch.
|
void |
setOffset(long offset)
Sets the offset for the clock.
|
static ClockWithOffset |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static ClockWithOffset[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ClockWithOffset INSTANCE
public static ClockWithOffset[] values()
for (ClockWithOffset c : ClockWithOffset.values()) System.out.println(c);
public static ClockWithOffset valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified namejava.lang.NullPointerException
- if the argument is nullpublic void setOffset(long offset)
offset
- Number of milliseconds to add to the current time.