Class TimeSource.SystemTimeSource
- java.lang.Object
-
- javax.time.TimeSource
-
- javax.time.TimeSource.SystemTimeSource
-
- All Implemented Interfaces:
java.io.Serializable
- Enclosing class:
- TimeSource
static final class TimeSource.SystemTimeSource extends TimeSource implements java.io.Serializable
Implementation of a time-source that always returns the latest time fromSystem.currentTimeMillis().
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.time.TimeSource
TimeSource.FixedTimeSource, TimeSource.OffsetSystemTimeSource, TimeSource.SystemTimeSource
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static TimeSource.SystemTimeSourceINSTANCESingleton instance.private static longserialVersionUIDA serialization identifier for this class.
-
Constructor Summary
Constructors Modifier Constructor Description privateSystemTimeSource()Restricted constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Instantinstant()Gets the currentInstant.longmillis()Gets the current millisecond instant.private java.lang.ObjectreadResolve()Resolve singletons.java.lang.StringtoString()-
Methods inherited from class javax.time.TimeSource
fixed, offsetSystem, system, taiInstant, utcInstant
-
-
-
-
Field Detail
-
INSTANCE
static final TimeSource.SystemTimeSource INSTANCE
Singleton instance.
-
serialVersionUID
private static final long serialVersionUID
A serialization identifier for this class.- See Also:
- Constant Field Values
-
-
Method Detail
-
readResolve
private java.lang.Object readResolve()
Resolve singletons.
-
instant
public Instant instant()
Gets the currentInstant.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 onSystem.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:
instantin classTimeSource- Returns:
- the current
Instantfrom 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 returnSystem.currentTimeMillis().This method is provided for backwards compatibility. New code should use classes such as
Instantto 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:
millisin classTimeSource- Returns:
- the current millisecond instant from this time-source, measured from the Java epoch of 1970-01-01T00:00 UTC, never null
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-