Interface Clock


public interface Clock
A clock abstraction used to measure absolute and relative time.
  • Field Summary

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

    Modifier and Type
    Method
    Description
    long
    Current monotonic time in nanoseconds.
    long
    Current time expressed as milliseconds since the Unix epoch.
  • Field Details

    • SYSTEM

      static final Clock SYSTEM
  • Method Details

    • wallTime

      long wallTime()
      Current time expressed as milliseconds since the Unix epoch. Should not be used for measuring time, just for timestamps.
      Returns:
      wall time in milliseconds
    • monotonicTime

      long monotonicTime()
      Current monotonic time in nanoseconds. Should be used for measuring time. The value is not related to the wall time and is not subject to system clock changes.
      Returns:
      monotonic time in nanoseconds