Package javax.time

Class TimeSource.SystemTimeSource

java.lang.Object
javax.time.TimeSource
javax.time.TimeSource.SystemTimeSource
All Implemented Interfaces:
Serializable
Enclosing class:
TimeSource

static final class TimeSource.SystemTimeSource extends TimeSource implements Serializable
Implementation of a time-source that always returns the latest time from System.currentTimeMillis().
  • Field Details

  • Constructor Details

    • SystemTimeSource

      private SystemTimeSource()
      Restricted constructor.
  • Method Details

    • readResolve

      private Object readResolve()
      Resolve singletons.
    • instant

      public Instant instant()
      Gets the current Instant.

      The instant returned by this method will vary according to the implementation. For example, the time-source returned by TimeSource.system() will return an instant based on System.currentTimeMillis().

      Normally, this method will not throw an exception. 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.

      Specified by:
      instant in class TimeSource
      Returns:
      the current Instant from this time-source, never null
    • millis

      public long millis()
      Gets the current millisecond instant.

      The instant returned by this method will vary according to the implementation. For example, the time-source returned by TimeSource.system() will return System.currentTimeMillis().

      This method is provided for backwards compatibility. New code should use classes such as Instant to represent an instant rather than a raw millisecond value.

      Normally, this method will not throw an exception. 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.

      Overrides:
      millis in class TimeSource
      Returns:
      the current millisecond instant from this time-source, measured from the Java epoch of 1970-01-01T00:00 UTC, never null
    • toString

      public String toString()
      Overrides:
      toString in class Object