Package spock.util.time
Class MutableClock
- java.lang.Object
-
- java.time.Clock
-
- spock.util.time.MutableClock
-
-
Constructor Summary
Constructors Constructor Description MutableClock()MutableClock(Instant instant)Initializes a with given instant andZoneId.systemDefault()and 1 secondchangeAmount.MutableClock(Instant instant, ZoneId zone)Initializes a with 1 secondchangeAmountand given parameters.MutableClock(Instant instant, ZoneId zone, TemporalAmount changeAmount)MutableClock(ZonedDateTime zonedDateTime)Initializes a with instant and zone fromZonedDateTimeand 1 secondchangeAmount.MutableClock(ZoneId zone)Initializes a withInstant.now()and given zone and 1 secondchangeAmount.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MutableClockadjust(TemporalAdjuster adjuster)Applies the givenTemporalAdjusterto the internal time.ZoneIdgetZone()Instantinstant()MutableClockminus(TemporalAmount amount)Subtracts the givenTemporalAmountfrom the internal time.MutableClockmodify(BiFunction<Instant,ZoneId,Instant> modification)Sets the internal time based on the result of the modification.MutableClocknext()AddschangeAmountto internal time.MutableClockplus(TemporalAmount amount)Adds the givenTemporalAmountto the internal time.MutableClockprevious()SubtractschangeAmountfrom internal time.voidsetChangeAmount(TemporalAmount changeAmount)voidsetInstant(Instant instant)StringtoString()MutableClockwithZone(ZoneId zone)-
Methods inherited from class java.time.Clock
equals, fixed, hashCode, millis, offset, system, systemDefaultZone, systemUTC, tick, tickMillis, tickMinutes, tickSeconds
-
-
-
-
Constructor Detail
-
MutableClock
public MutableClock()
-
MutableClock
public MutableClock(Instant instant)
Initializes a with given instant andZoneId.systemDefault()and 1 secondchangeAmount.- Parameters:
instant- to use
-
MutableClock
public MutableClock(ZoneId zone)
Initializes a withInstant.now()and given zone and 1 secondchangeAmount.- Parameters:
zone- to use
-
MutableClock
public MutableClock(Instant instant, ZoneId zone)
Initializes a with 1 secondchangeAmountand given parameters.- Parameters:
instant- to usezone- to use
-
MutableClock
public MutableClock(Instant instant, ZoneId zone, TemporalAmount changeAmount)
-
MutableClock
public MutableClock(ZonedDateTime zonedDateTime)
Initializes a with instant and zone fromZonedDateTimeand 1 secondchangeAmount.- Parameters:
zonedDateTime- to use for instant and zone information
-
-
Method Detail
-
withZone
public MutableClock withZone(ZoneId zone)
-
setChangeAmount
public void setChangeAmount(TemporalAmount changeAmount)
-
setInstant
public void setInstant(Instant instant)
-
modify
public MutableClock modify(BiFunction<Instant,ZoneId,Instant> modification)
Sets the internal time based on the result of the modification.- Parameters:
modification- a function to produce a new Instant- Returns:
- this
-
plus
public MutableClock plus(TemporalAmount amount)
Adds the givenTemporalAmountto the internal time.- Parameters:
amount- to add- Returns:
- this
-
minus
public MutableClock minus(TemporalAmount amount)
Subtracts the givenTemporalAmountfrom the internal time.- Parameters:
amount- to subtract- Returns:
- this
-
adjust
public MutableClock adjust(TemporalAdjuster adjuster)
Applies the givenTemporalAdjusterto the internal time.- Parameters:
adjuster- the adjuster to use,- Returns:
- this
-
next
public MutableClock next()
AddschangeAmountto internal time.- Returns:
- this
-
previous
public MutableClock previous()
SubtractschangeAmountfrom internal time.- Returns:
- this
-
-