Enum Class SystemClockUtc

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

public enum SystemClockUtc extends Enum<SystemClockUtc> implements SystemClock
A clock based off of the current system time.
See Also:
  • Enum Constant Details

  • Method Details

    • values

      public static SystemClockUtc[] 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 SystemClockUtc 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()
      Milliseconds since the epoch, 1970-01-01T00:00:00Z.

      The resolution is dependent on the JVM and underlying implementation.

      Equivalent to System.currentTimeMillis(). This is the same source as Clock.systemUTC().

      Specified by:
      currentTimeMillis in interface Clock
      Returns:
      the current system time in epoch millis
    • currentTimeMicros

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

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

      Note: this method may allocate.

      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 java.time.Clock.systemUTC().instant().

      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.