Interface Clock

All Known Implementing Classes:
Clock.ManualClock, Clock.SystemClock

public interface Clock
  • Method Details

    • now

      Instant now()
      Returns:
      the current time of the clock.
    • sleep

      void sleep(Duration duration) throws InterruptedException
      Sleeps for the given duration.

      For system clock, this performs an actual sleep by calling Thread.sleep(long). For manual clock, this advances the clock time by the given duration without sleeping.

      Parameters:
      duration - the duration to sleep
      Throws:
      InterruptedException - if the sleep is interrupted (only for system clock)
    • systemClock

      static Clock systemClock()
    • manualClock

      static Clock manualClock(Instant now)
    • getManualClock

      static Clock getManualClock(String name)
    • removeManualClock

      static void removeManualClock(String name)