public abstract class Clock
A clock marks the passing of time.
It has a concept of now that can be queried through
Clock.getTime(), and it can have events
queued on it which will be fired when their appointed time is reached.
Constructor for the abstract class.
Returns the relative time of the offset of the epoch of
There is always at least one clock object available: the system real-time clock.
Gets the resolution of the clock, the nominal interval between ticks.
Gets the current time in a newly allocated object.
Gets the current time in an existing object.
Set the resolution of
|Methods inherited from class java.lang.Object|
public abstract RelativeTime getEpochOffset()
thisclock from the Epoch. For the real-time clock it will return a RelativeTime value equal to 0. An
UnsupportedOperationExceptionis thrown if the clock does not support the concept of date.
RelativeTimeobject in the current execution context with the offset past the Epoch for
thisclock. The returned object is associated with
java.lang.UnsupportedOperationException- Thrown if the clock does not have the concept of date.
public static Clock getRealtimeClock()
public abstract RelativeTime getResolution()
RelativeTimeobject in the current execution context representing the resolution of
this. The returned object is associated with
public abstract AbsoluteTime getTime()
AbsoluteTimein the current allocation context, representing the current time. The returned object is associated with
public abstract AbsoluteTime getTime(AbsoluteTime dest)
AbsoluteTimeis changed at some time between the invocation of the method and the return of the method. Note: This method will return an absolute time value that represents the clock's notion of an absolute time. For clocks that do not measure calendar time this absolute time may not represent a wall clock time.
dest- The instance of
AbsoluteTimeobject which will be updated in place. The clock association of the
destparameter is ignored. When
nullthe returned object is associated with
null, then nothing happens.
AbsoluteTimepassed as parameter, representing the current time, associated with
public abstract void setResolution(RelativeTime resolution)
this. For some hardware clocks setting resolution is impossible and if this method is called on those clocks, then an
resolution- The new resolution of
this, if the requested value is supported by
resolutionis smaller than the minimum resolution supported by
thisclock then it throws
IllegalArgumentException. If the requested
resolutionis not available and it is larger than the minimum resolution, then the clock will be set to the closest resolution that the clock supports, via truncation. The value of the
resolutionparameter is not altered. The clock association of the
resolutionparameter is ignored.
java.lang.IllegalArgumentException- Thrown if
null, or if the requested
resolutionis smaller than the minimum resolution supported by this clock.
java.lang.UnsupportedOperationException- Thrown if the clock does not support setting its resolution.