Interface Clock

All Superinterfaces:
Wrapper

public interface Clock extends Wrapper
Reports absolute time (and, therefore, is also useful in computing elapsed times).
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the current time in nanoseconds from a monotonic clock source.
    static Clock
    Returns the system clock for the Helidon metrics implementation.
    default <R> R
    unwrap(Class<? extends R> c)
    Unwraps the clock to the specified type (typically not needed for custom clocks).
    long
    Returns the current wall time in milliseconds since the epoch.
  • Method Details

    • system

      static Clock system()
      Returns the system clock for the Helidon metrics implementation.

      The system clock methods are functionally equivalent to System.currentTimeMillis() and System.nanoTime().

      Returns:
      the system clock
    • wallTime

      long wallTime()
      Returns the current wall time in milliseconds since the epoch.

      Typically equivalent to System.currentTimeMillis(). Should not be used to determine durations. For that use monotonicTime() instead.

      Returns:
      wall time in milliseconds
    • monotonicTime

      long monotonicTime()
      Returns the current time in nanoseconds from a monotonic clock source.

      The value is only meaningful when compared with another value returned from this method to determine the elapsed time for an operation. The difference between two samples will have a unit of nanoseconds. The returned value is typically equivalent to System.nanoTime().

      Returns:
      monotonic time in nanoseconds
    • unwrap

      default <R> R unwrap(Class<? extends R> c)
      Unwraps the clock to the specified type (typically not needed for custom clocks).
      Specified by:
      unwrap in interface Wrapper
      Type Parameters:
      R - the type of the unwrapped clock
      Parameters:
      c - Class to which to cast this object
      Returns:
      unwrapped clock