Interface ClockAdjuster

All Known Implementing Classes:
ControllableClock

public interface ClockAdjuster
A clock adjusting API, e.g. offered by a ControllableClock. This interface can for instance be used to easily expose time manipulation through another API, but you do not want to expose a Clock or ControllableClock instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Freeze the clock at its current instant in time.
    void
    freezeAt(Instant instant)
    Freeze the clock at given instant.
    void
    freezeAt(Instant instant, ZoneId zone)
    Freeze the clock at given instant and zone.
    void
    freezeAt(LocalDateTime offsetDateTime)
    Freeze the clock at given date and time.
    void
    freezeAt(OffsetDateTime offsetDateTime)
    Freeze the clock at given date and time.
    void
    freezeAt(ZonedDateTime zonedDateTime)
    Freeze the clock at given date and time.
    void
    Freeze the clock at its current instant in time, which will be truncated to the given unit.
    void
    set(Instant instant)
    Set the time to the given instant.
    void
    set(Instant instant, ZoneId zone)
    Set the time of the clock to the given instant and zone.
    void
    set(LocalDateTime localDateTime)
    Set the time to the given local date and time.
    void
    set(OffsetDateTime offsetDateTime)
    Set the time to the given offset date and time.
    void
    set(ZonedDateTime zonedDateTime)
    Set the time to the given zoned date and time.
    void
    set(UnaryOperator<Clock> createNewClock)
    Set a new clock to resolve the time from.
    void
    Set the time to freely progressing system time.
    void
    Set the time to freely progressing system time with the given zone.
    void
    timePasses(Duration amountOfTime)
    Signal that time is passing a given amount of time.
    void
    timePasses(TemporalAmount amountOfTime)
    Signal that time is passing a given amount of time.
  • Method Details

    • set

      void set(UnaryOperator<Clock> createNewClock)
      Set a new clock to resolve the time from.
      Parameters:
      createNewClock - function which is given the current clock, which may be used to create a new clock.
    • timePasses

      void timePasses(Duration amountOfTime)
      Signal that time is passing a given amount of time.
      Parameters:
      amountOfTime - the amount of time which are passing.
    • timePasses

      void timePasses(TemporalAmount amountOfTime)
      Signal that time is passing a given amount of time.
      Parameters:
      amountOfTime - the amount of time which are passing.
    • freezeAt

      void freezeAt(Instant instant, ZoneId zone)
      Freeze the clock at given instant and zone.
    • freezeAt

      void freezeAt(Instant instant)
      Freeze the clock at given instant.
    • freezeAt

      void freezeAt(ZonedDateTime zonedDateTime)
      Freeze the clock at given date and time.
    • freezeAt

      void freezeAt(OffsetDateTime offsetDateTime)
      Freeze the clock at given date and time.
    • freezeAt

      void freezeAt(LocalDateTime offsetDateTime)
      Freeze the clock at given date and time.
    • freeze

      void freeze()
      Freeze the clock at its current instant in time.
    • freezeTruncatedTo

      void freezeTruncatedTo(TemporalUnit unit)
      Freeze the clock at its current instant in time, which will be truncated to the given unit.
      Parameters:
      unit - the unit the freezed instant will be truncated to
      See Also:
    • setToSystemClock

      void setToSystemClock(ZoneId zoneId)
      Set the time to freely progressing system time with the given zone.
      See Also:
    • setToSystemClock

      void setToSystemClock()
      Set the time to freely progressing system time.
      See Also:
    • set

      void set(Instant instant, ZoneId zone)
      Set the time of the clock to the given instant and zone.
      Parameters:
      instant - the instant to set.
      zone - the zone to set.
    • set

      void set(Instant instant)
      Set the time to the given instant.
      Parameters:
      instant - the instant to set.
    • set

      void set(ZonedDateTime zonedDateTime)
      Set the time to the given zoned date and time.
      Parameters:
      zonedDateTime - the date and time to set.
    • set

      void set(OffsetDateTime offsetDateTime)
      Set the time to the given offset date and time.
      Parameters:
      offsetDateTime - the date and time to set.
    • set

      void set(LocalDateTime localDateTime)
      Set the time to the given local date and time.
      Parameters:
      localDateTime - the date and time to set.