public abstract class Clock extends java.lang.Object implements Chronograph
A clock provides means to determine the current time (now) with a given resolution.
| Constructor and Description |
|---|
Clock()
Constructor to be called by subclasses of Clock.
|
| Modifier and Type | Method and Description |
|---|---|
RelativeTime |
getEpochOffset()
Determines the time on the UTC clock when this chronograph was
zero.
|
RelativeTime |
getQueryPrecision()
Obtain the precision with which time can be read, i.e., the nominal
interval between ticks.
|
RelativeTime |
getQueryPrecision(RelativeTime dest)
Obtain the precision with which time can be read, i.e., the nominal
interval between ticks.
|
static Clock |
getRealtimeClock()
Returns the default RealtimeClock.
|
abstract RelativeTime |
getResolution()
Returns the resolution of this clock, i.e.
|
AbsoluteTime |
getTime()
Determines the current time.
|
abstract AbsoluteTime |
getTime(AbsoluteTime time)
Obtain the current time.
|
abstract void |
setResolution(RelativeTime resolution)
Sets the resolution of this time to the provided value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetEpochOffsetpublic Clock()
Since this class is abstract, this constructor cannot be called from a class that is not a sub-class of Clock, it should therefore better be protected.
public static Clock getRealtimeClock()
For JamaicaVM, on systems that have a timer that is synchronized with the external world, this returns a RealtimeClock that is synchronized with the external world. On systems whose timer is not synchronized with the external world, the time of the returned RealtimeClock may be different to the time used by the external world (e.g., the epoch may start at system boot time).
public RelativeTime getEpochOffset() throws StaticUnsupportedOperationException, UninitializedStateException
getEpochOffset in interface ChronographRelativeTime object in the current
execution context with the realtime clock as its chronograph
and containing time when this chronograph was zero.StaticUnsupportedOperationExceptionUninitializedStateException - when UTC time is not yet available.public abstract RelativeTime getResolution()
public AbsoluteTime getTime()
ChronographgetTime in interface ChronographAbsoluteTime in the
current allocation context, representing the current time.
The returned object has this its chronograph.public abstract AbsoluteTime getTime(AbsoluteTime time)
AbsoluteTime is changed at some time between the invocation of the
method and the return of the method. This method will return an absolute
time value that represents this chronograph's notion of the absolute time.
For chronographs that do not measure calendar time, this absolute time may
not represent a wall clock time.getTime in interface Chronographtime - The instance of AbsoluteTime object which will be
updated in place.AbsoluteTime passed as parameter, or a new
object when dest is null. The returned object
represents the current time and is associated with this
chronograph.public abstract void setResolution(RelativeTime resolution)
resolution - the new resolution.StaticIllegalArgumentException - if parameter is null or
represents a negative or zero interval.java.lang.UnsupportedOperationException - if setting of the timer is
not supported for the given system.public RelativeTime getQueryPrecision()
ChronographChronograph.getQueryPrecision(RelativeTime) with null as an argument.getQueryPrecision in interface Chronographpublic RelativeTime getQueryPrecision(RelativeTime dest)
ChronographgetQueryPrecision in interface Chronographdest - is a time object in which to return the results.dest, when dest is not
null, or in a newly created object otherwise.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2021 aicas GmbH. All Rights Reserved.