public interface TimeSource
This clock differs from Clock
in providing access to the current instant
in the UTC and TAI time-scales. However, there is currently no implementation that
provides accurate UTC or TAI.
The principal methods are defined to allow the throwing of an exception. In normal use, no exceptions will be thrown, however one possible implementation would be to obtain the time from a central time server across the network. Obviously, in this case the lookup could fail, and so the method is permitted to throw an exception.
Subclass implementations should implement Serializable
wherever possible.
They should also be immutable and thread-safe, implementing equals()
,
hashCode()
and toString()
based on their state.
Modifier and Type | Method and Description |
---|---|
java.time.Instant |
instant()
Gets the current
Instant . |
TaiInstant |
taiInstant()
Gets the current
TaiInstant . |
UtcInstant |
utcInstant()
Gets the current
UtcInstant . |
java.time.Instant instant()
Instant
.
The instant returned is based on the Java time-scale defined in Instant
.
An accurate implementation of this interface will return the correct instant
as per that definition.
Instant
from this time-source, not nullRuntimeException
- if the instant cannot be obtained, not thrown by most implementationsUtcInstant utcInstant()
UtcInstant
.
The UTC time-scale is the current world civil time and includes leap seconds. An accurate implementation of this interface will return the correct UTC instant.
UtcInstant
from this time-source, not nullRuntimeException
- if the instant cannot be obtained, not thrown by most implementationsTaiInstant taiInstant()
TaiInstant
.
The TAI time-scale is a simple incrementing number of seconds from the TAI epoch of 1958-01-01(TAI). It ignores all human concepts of time such as days. An accurate implementation of this interface will return the correct TAI instant.
TaiInstant
from this time-source, not nullRuntimeException
- if the instant cannot be obtained, not thrown by most implementationsCopyright © 2010–2014 ThreeTen.org. All rights reserved.