public class MutableClock
extends java.time.Clock
Clock
for testing purposes.Constructor and Description |
---|
MutableClock()
|
MutableClock(java.time.Instant instant)
Initializes a with given instant and
ZoneId.systemDefault() and 1 second changeAmount . |
MutableClock(java.time.Instant instant,
java.time.ZoneId zone)
Initializes a with 1 second
changeAmount and given parameters. |
MutableClock(java.time.Instant instant,
java.time.ZoneId zone,
java.time.temporal.TemporalAmount changeAmount) |
MutableClock(java.time.ZonedDateTime zonedDateTime)
Initializes a with instant and zone from
ZonedDateTime and 1 second changeAmount . |
MutableClock(java.time.ZoneId zone)
Initializes a with
Instant.now() and given zone and 1 second changeAmount . |
Modifier and Type | Method and Description |
---|---|
MutableClock |
adjust(java.time.temporal.TemporalAdjuster adjuster)
Applies the given
TemporalAdjuster to the internal time. |
java.time.ZoneId |
getZone() |
java.time.Instant |
instant() |
MutableClock |
minus(java.time.temporal.TemporalAmount amount)
Subtracts the given
TemporalAmount from the internal time. |
MutableClock |
modify(java.util.function.BiFunction<java.time.Instant,java.time.ZoneId,java.time.Instant> modification)
Sets the internal time based on the result of the modification.
|
MutableClock |
next()
Adds
changeAmount to internal time. |
MutableClock |
plus(java.time.temporal.TemporalAmount amount)
Adds the given
TemporalAmount to the internal time. |
MutableClock |
previous()
Subtracts
changeAmount from internal time. |
void |
setChangeAmount(java.time.temporal.TemporalAmount changeAmount) |
void |
setInstant(java.time.Instant instant) |
java.lang.String |
toString() |
MutableClock |
withZone(java.time.ZoneId zone) |
public MutableClock()
public MutableClock(java.time.Instant instant)
ZoneId.systemDefault()
and 1 second changeAmount
.instant
- to usepublic MutableClock(java.time.ZoneId zone)
Instant.now()
and given zone and 1 second changeAmount
.zone
- to usepublic MutableClock(java.time.Instant instant, java.time.ZoneId zone)
changeAmount
and given parameters.instant
- to usezone
- to usepublic MutableClock(java.time.Instant instant, java.time.ZoneId zone, java.time.temporal.TemporalAmount changeAmount)
public MutableClock(java.time.ZonedDateTime zonedDateTime)
ZonedDateTime
and 1 second changeAmount
.zonedDateTime
- to use for instant and zone informationpublic java.time.ZoneId getZone()
getZone
in class java.time.Clock
public MutableClock withZone(java.time.ZoneId zone)
withZone
in class java.time.Clock
public java.time.Instant instant()
instant
in class java.time.Clock
public void setChangeAmount(java.time.temporal.TemporalAmount changeAmount)
public void setInstant(java.time.Instant instant)
public MutableClock modify(java.util.function.BiFunction<java.time.Instant,java.time.ZoneId,java.time.Instant> modification)
modification
- a function to produce a new Instantpublic MutableClock plus(java.time.temporal.TemporalAmount amount)
TemporalAmount
to the internal time.amount
- to addpublic MutableClock minus(java.time.temporal.TemporalAmount amount)
TemporalAmount
from the internal time.amount
- to subtractpublic MutableClock adjust(java.time.temporal.TemporalAdjuster adjuster)
TemporalAdjuster
to the internal time.adjuster
- the adjuster to use,public MutableClock next()
changeAmount
to internal time.public MutableClock previous()
changeAmount
from internal time.public java.lang.String toString()
toString
in class java.lang.Object