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 secondchangeAmount
and given parameters.MutableClock(Instant instant, ZoneId zone, TemporalAmount changeAmount)
MutableClock(ZonedDateTime zonedDateTime)
Initializes a with instant and zone fromZonedDateTime
and 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 MutableClock
adjust(TemporalAdjuster adjuster)
Applies the givenTemporalAdjuster
to the internal time.ZoneId
getZone()
Instant
instant()
MutableClock
minus(TemporalAmount amount)
Subtracts the givenTemporalAmount
from the internal time.MutableClock
modify(BiFunction<Instant,ZoneId,Instant> modification)
Sets the internal time based on the result of the modification.MutableClock
next()
AddschangeAmount
to internal time.MutableClock
plus(TemporalAmount amount)
Adds the givenTemporalAmount
to the internal time.MutableClock
previous()
SubtractschangeAmount
from internal time.void
setChangeAmount(TemporalAmount changeAmount)
void
setInstant(Instant instant)
String
toString()
MutableClock
withZone(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 secondchangeAmount
and 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 fromZonedDateTime
and 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 givenTemporalAmount
to the internal time.- Parameters:
amount
- to add- Returns:
- this
-
minus
public MutableClock minus(TemporalAmount amount)
Subtracts the givenTemporalAmount
from the internal time.- Parameters:
amount
- to subtract- Returns:
- this
-
adjust
public MutableClock adjust(TemporalAdjuster adjuster)
Applies the givenTemporalAdjuster
to the internal time.- Parameters:
adjuster
- the adjuster to use,- Returns:
- this
-
next
public MutableClock next()
AddschangeAmount
to internal time.- Returns:
- this
-
previous
public MutableClock previous()
SubtractschangeAmount
from internal time.- Returns:
- this
-
-