Interface Clock

All Known Implementing Classes:
MockClock

public interface Clock
Used to measure absolute and relative time.
See Also:
for a clock that can be manually advanced for use in tests.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static Clock SYSTEM  
  • Method Summary

    Modifier and Type Method Description
    long monotonicTime()
    Current time from a monotonic clock source.
    long wallTime()
    Current wall time in milliseconds since the epoch.
  • Field Details

    • SYSTEM

      static final Clock SYSTEM
  • Method Details

    • wallTime

      long wallTime()
      Current wall time in milliseconds since the epoch. Typically equivalent to System.currentTimeMillis. Should not be used to determine durations. Used for timestamping metrics being pushed to a monitoring system or for determination of step boundaries (e.g. StepLong.
      Returns:
      Wall time in milliseconds
    • monotonicTime

      long monotonicTime()
      Current time from a monotonic clock source. The value is only meaningful when compared with another snapshot 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