Package io.jenetics.util
Class NanoClock
- java.lang.Object
-
- java.time.Clock
-
- io.jenetics.util.NanoClock
-
- All Implemented Interfaces:
Serializable
public final class NanoClock extends Clock implements Serializable
Clock implementation with nano second precision.- Since:
- 3.1
- Version:
- 3.1
- Author:
- Franz Wilhelmstötter
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static long
NANOS_PER_SECOND
This constants holds the number of nano seconds of one second.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
ZoneId
getZone()
int
hashCode()
Instant
instant()
long
millis()
long
nanos()
This returns the nanosecond-based instant, measured from 1970-01-01T00:00Z (UTC).static NanoClock
system(ZoneId zone)
This clock is based on the nano system clock.static NanoClock
systemDefaultZone()
This clock is based on the nano system clock.static NanoClock
systemUTC()
This clock is based on the nano system clock.String
toString()
NanoClock
withZone(ZoneId zone)
-
Methods inherited from class java.time.Clock
fixed, offset, tick, tickMillis, tickMinutes, tickSeconds
-
-
-
-
Field Detail
-
NANOS_PER_SECOND
public static final long NANOS_PER_SECOND
This constants holds the number of nano seconds of one second.- See Also:
- Constant Field Values
-
-
Method Detail
-
nanos
public long nanos()
This returns the nanosecond-based instant, measured from 1970-01-01T00:00Z (UTC). This method will return valid values till the year 2262.- Returns:
- the nanosecond-based instant, measured from 1970-01-01T00:00Z (UTC)
-
system
public static NanoClock system(ZoneId zone)
This clock is based on the nano system clock. It usesSystem.nanoTime()
resolutionConversion from instant to date or time uses the specified time-zone.
The returned implementation is immutable, thread-safe and
Serializable
.- Parameters:
zone
- the time-zone to use to convert the instant to date-time- Returns:
- a clock that uses the best available system clock in the specified zone
- Throws:
NullPointerException
- if the givenzone
isnull
-
systemUTC
public static NanoClock systemUTC()
This clock is based on the nano system clock. It usesSystem.nanoTime()
resolutionConversion from instant to date or time uses the specified time-zone.
The returned implementation is immutable, thread-safe and
Serializable
.- Returns:
- a clock that uses the best available system clock in the UTC zone
- Throws:
NullPointerException
- if the givenzone
isnull
-
systemDefaultZone
public static NanoClock systemDefaultZone()
This clock is based on the nano system clock. It usesSystem.nanoTime()
resolutionConversion from instant to date or time uses the specified time-zone.
The returned implementation is immutable, thread-safe and
Serializable
.- Returns:
- a clock that uses the best available system clock in the default zone
- Throws:
NullPointerException
- if the givenzone
isnull
-
-