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, implementing equals(), hashCode() and toString() based on their state.

    • Method Detail

      • instant

        Instant instant()
        Gets the current 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.

        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 current 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.

        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 current 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.

        Returns:
        the current TaiInstant from this time-source, not null
        Throws:
        RuntimeException - if the instant cannot be obtained, not thrown by most implementations