Enum Class SystemClockMillis

java.lang.Object
java.lang.Enum<SystemClockMillis>
io.deephaven.base.clock.SystemClockMillis
All Implemented Interfaces:
Clock, SystemClock, Serializable, Comparable<SystemClockMillis>, java.lang.constant.Constable

public enum SystemClockMillis extends Enum<SystemClockMillis> implements SystemClock
A clock based off of System.currentTimeMillis().

This clock differs from SystemClockUtc in that all timestamp methods have millisecond-level resolution.

  • Enum Constant Details

  • Method Details

    • values

      public static SystemClockMillis[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static SystemClockMillis valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • currentTimeMillis

      public long currentTimeMillis()
      Specified by:
      currentTimeMillis in interface Clock
      Returns:
      epoch millis
    • currentTimeMicros

      public long currentTimeMicros()
      Equivalent to System.currentTimeMillis() * 1_000.
      Specified by:
      currentTimeMicros in interface Clock
      Returns:
      epoch microseconds
    • currentTimeNanos

      public long currentTimeNanos()
      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().

      Calculates the time from Clock.systemUTC(). If you don't need nanosecond resolution, prefer currentTimeMillis().

      Note: this method may allocate.

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

      public Instant instantNanos()
      The instant.

      Has resolution equal to Clock.currentTimeNanos().

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

      Equivalent to Instant.ofEpochMilli(System.currentTimeMillis()).

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

      public Instant instantMillis()
      The instant.

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

      Equivalent to Instant.ofEpochMilli(System.currentTimeMillis()).

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