Class ClockUtils

java.lang.Object
org.axonframework.common.ClockUtils

public final class ClockUtils extends Object
Global access point for the framework's current Clock.

This utility provides a shared clock abstraction that can be read from anywhere in the framework and overridden in tests or integration scenarios. It also implements InstantSource so callers can use it wherever an instant source is required.

Since:
5.2.0
Author:
Jan Galinski
  • Field Details

    • SUPPLIER

      public static final Supplier<Instant> SUPPLIER
      A supplier that returns the current instant of the global clock.
  • Method Details

    • get

      public static Clock get()
      Returns the currently configured global clock.
      Returns:
      the shared clock instance, or the default UTC clock if none has been configured explicitly
    • set

      public static Clock set(Clock clock)
      Replaces the currently configured global clock.
      Parameters:
      clock - the new global clock to use
      Returns:
      the clock that was installed
    • reset

      public static Clock reset()
      Restores the global clock to the default UTC clock.
      Returns:
      the default UTC clock
    • instant

      public static Instant instant()
      Adapts the current clock to the InstantSource interface.
      Returns:
      the InstantSource.instant() of the current clock