Package javax.time
Class TimeSource.FixedTimeSource
- java.lang.Object
-
- javax.time.TimeSource
-
- javax.time.TimeSource.FixedTimeSource
-
- All Implemented Interfaces:
java.io.Serializable
- Enclosing class:
- TimeSource
static final class TimeSource.FixedTimeSource extends TimeSource implements java.io.Serializable
Implementation of a time-source that always returns the same instant. This is typically used for testing.
-
-
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 private Instant
instant
The fixed instant to return.private static long
serialVersionUID
A serialization identifier for this class.
-
Constructor Summary
Constructors Modifier Constructor Description private
FixedTimeSource(Instant fixedInstant)
Restricted constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
int
hashCode()
Instant
instant()
Gets the currentInstant
.java.lang.String
toString()
-
Methods inherited from class javax.time.TimeSource
fixed, millis, offsetSystem, system, taiInstant, utcInstant
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
A serialization identifier for this class.- See Also:
- Constant Field Values
-
instant
private final Instant instant
The fixed instant to return.
-
-
Constructor Detail
-
FixedTimeSource
private FixedTimeSource(Instant fixedInstant)
Restricted constructor.
-
-
Method Detail
-
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:
instant
in classTimeSource
- Returns:
- the current
Instant
from this time-source, never null
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-