Interface TimeSource
-
public interface TimeSource
A clock that provides the current UTC or TAI instant.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.Implementation Requirements:
This abstract class must be implemented with care to ensure other classes in the framework operate correctly. All implementations that can be instantiated must be final, immutable and thread-safe.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, implementingequals()
,hashCode()
andtoString()
based on their state.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Instant
instant()
Gets the currentInstant
.TaiInstant
taiInstant()
Gets the currentTaiInstant
.UtcInstant
utcInstant()
Gets the currentUtcInstant
.
-
-
-
Method Detail
-
instant
Instant instant()
Gets the currentInstant
.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.- Returns:
- the current
Instant
from this time-source, not null - Throws:
RuntimeException
- if the instant cannot be obtained, not thrown by most implementations
-
utcInstant
UtcInstant utcInstant()
Gets the currentUtcInstant
.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.
- Returns:
- the current
UtcInstant
from this time-source, not null - Throws:
RuntimeException
- if the instant cannot be obtained, not thrown by most implementations
-
taiInstant
TaiInstant taiInstant()
Gets the currentTaiInstant
.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.
- Returns:
- the current
TaiInstant
from this time-source, not null - Throws:
RuntimeException
- if the instant cannot be obtained, not thrown by most implementations
-
-