Class NanoClock

java.lang.Object
java.time.Clock
io.jenetics.util.NanoClock
All Implemented Interfaces:
Serializable, InstantSource

public final class NanoClock extends Clock implements Serializable
Clock implementation with nano second precision.
Since:
3.1
Version:
3.1
See Also:
  • Field Details

  • Method Details

    • getZone

      public ZoneId getZone()
      Specified by:
      getZone in class Clock
    • withZone

      public NanoClock withZone(ZoneId zone)
      Specified by:
      withZone in interface InstantSource
      Specified by:
      withZone in class Clock
    • millis

      public long millis()
      Specified by:
      millis in interface InstantSource
      Overrides:
      millis in class Clock
    • 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)
    • instant

      public Instant instant()
      Specified by:
      instant in interface InstantSource
      Specified by:
      instant in class Clock
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Clock
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Clock
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • system

      public static NanoClock system(ZoneId zone)
      This clock is based on the nano system clock. It uses System.nanoTime() resolution

      Conversion 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 given zone is null
    • systemUTC

      public static NanoClock systemUTC()
      This clock is based on the nano system clock. It uses System.nanoTime() resolution

      Conversion 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 given zone is null
    • systemDefaultZone

      public static NanoClock systemDefaultZone()
      This clock is based on the nano system clock. It uses System.nanoTime() resolution

      Conversion 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 given zone is null