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 Detail

      • 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:
        ChronoUnit, Instant.truncatedTo(TemporalUnit)
      • setToSystemClock

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

        void setToSystemClock()
        Set the time to freely progressing system time.
        See Also:
        Clock.system(ZoneId)
      • 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.