Package no.digipost.time
Interface ClockAdjuster
-
- All Known Implementing Classes:
ControllableClock
public interface ClockAdjusterA clock adjusting API, e.g. offered by aControllableClock. This interface can for instance be used to easily expose time manipulation through another API, but you do not want to expose aClockorControllableClockinstance.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidfreeze()Freeze the clock at its current instant in time.voidfreezeAt(Instant instant)Freeze the clock at given instant.voidfreezeAt(Instant instant, ZoneId zone)Freeze the clock at given instant andzone.voidfreezeAt(LocalDateTime offsetDateTime)Freeze the clock at given date and time.voidfreezeAt(OffsetDateTime offsetDateTime)Freeze the clock at given date and time.voidfreezeAt(ZonedDateTime zonedDateTime)Freeze the clock at given date and time.voidfreezeTruncatedTo(TemporalUnit unit)Freeze the clock at its current instant in time, which will be truncated to the given unit.voidset(Instant instant)Set the time to the given instant.voidset(Instant instant, ZoneId zone)Set the time of the clock to the given instant and zone.voidset(LocalDateTime localDateTime)Set the time to the given local date and time.voidset(OffsetDateTime offsetDateTime)Set the time to the given offset date and time.voidset(ZonedDateTime zonedDateTime)Set the time to the given zoned date and time.voidset(UnaryOperator<Clock> createNewClock)Set a new clock to resolve the time from.voidsetToSystemClock()Set the time to freely progressing system time.voidsetToSystemClock(ZoneId zoneId)Set the time to freely progressing system time with the given zone.voidtimePasses(Duration amountOfTime)Signal that time is passing a given amount of time.voidtimePasses(TemporalAmount amountOfTime)Signal that time is passing a given amount of time.
-
-
-
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)
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.
-
-