Class DeltaClock

java.lang.Object
io.deephaven.base.clock.DeltaClock
All Implemented Interfaces:
Clock

public final class DeltaClock extends Object implements Clock
A clock impl with a delta adjustment.
  • Constructor Details

    • DeltaClock

      public DeltaClock(long deltaNanos)
      Constructs a delta clock with a Clock.system() clock.
      Parameters:
      deltaNanos - the delta nanos
    • DeltaClock

      public DeltaClock(Clock delegate, long deltaNanos)
      Constructs a delta clock with the provided clock and delta.
      Parameters:
      delegate - the base clock
      deltaNanos - the delta nanos
  • Method Details

    • of

      public static DeltaClock of(Duration duration)
      Constructs a delta clock with a Clock.system() clock.
      Parameters:
      duration - the duration
      Returns:
      the clock
    • currentTimeMillis

      public long currentTimeMillis()
      Description copied from interface: Clock
      Milliseconds since the epoch, 1970-01-01T00:00:00Z.

      The resolution is dependent on the JVM and underlying implementation.

      Specified by:
      currentTimeMillis in interface Clock
      Returns:
      epoch millis
    • currentTimeMicros

      public long currentTimeMicros()
      Description copied from interface: Clock
      Microseconds since the epoch, 1970-01-01T00:00:00Z.

      The resolution is dependent on the JVM and underlying implementation. The resolution is greater than or equal to Clock.currentTimeMillis().

      Specified by:
      currentTimeMicros in interface Clock
      Returns:
      epoch microseconds
    • currentTimeNanos

      public long currentTimeNanos()
      Description copied from interface: Clock
      Nanoseconds since the epoch, 1970-01-01T00:00:00Z.

      The resolution is dependent on the JVM and underlying implementation. The resolution is greater than or equal to Clock.currentTimeMicros() and Clock.currentTimeMillis().

      Specified by:
      currentTimeNanos in interface Clock
      Returns:
      epoch nanoseconds
    • instantNanos

      public Instant instantNanos()
      Description copied from interface: Clock
      The instant.

      Has resolution equal to Clock.currentTimeNanos().

      If you don't need the resolution provided by Clock.currentTimeNanos(), prefer Clock.instantMillis().

      Specified by:
      instantNanos in interface Clock
      Returns:
      the instant
    • instantMillis

      public Instant instantMillis()
      Description copied from interface: Clock
      The instant.

      Has resolution greater than or equal to Clock.currentTimeMillis().

      Specified by:
      instantMillis in interface Clock
      Returns:
      the instant.