public class SchedulerClock extends Clock
Scheduler
. That adoption gives better integration with
Java 8 DateTime API.
This feature may be useful for testing purpose, especially for integration with VirtualTimeScheduler
. For example:
VirtualTimeScheduler scheduler = VirtualTimeScheduler.create();
SchedulerClock clock = SchedulerClock.of(scheduler);
ZonedDateTime beforeAdvance = ZonedDateTime.now(clock);
scheduler.advanceTimeBy(Duration.ofSeconds(1));
ZonedDateTime afterAdvance = ZonedDateTime.now(clock);
Assert.assertTrue(beforeAdvance.isBefore(afterAdvance));
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
reactor.core.scheduler.Scheduler |
getScheduler()
Return wrapped Scheduler instance
|
ZoneId |
getZone() |
int |
hashCode() |
Instant |
instant()
Gets the current instant of the clock.
|
long |
millis() |
static SchedulerClock |
of(reactor.core.scheduler.Scheduler scheduler)
|
static SchedulerClock |
of(reactor.core.scheduler.Scheduler scheduler,
ZoneId zoneId)
|
String |
toString() |
SchedulerClock |
withScheduler(reactor.core.scheduler.Scheduler scheduler)
Builder method that returns new instance of
SchedulerClock which is
constructed from old ZoneId and passed Scheduler instance |
SchedulerClock |
withZone(ZoneId zone) |
fixed, offset, system, systemDefaultZone, systemUTC, tick, tickMinutes, tickSeconds
@NonNull public SchedulerClock withZone(ZoneId zone)
@NonNull public reactor.core.scheduler.Scheduler getScheduler()
Scheduler
instance@NonNull public SchedulerClock withScheduler(reactor.core.scheduler.Scheduler scheduler)
SchedulerClock
which is
constructed from old ZoneId
and passed Scheduler
instanceSchedulerClock
instance@NonNull public Instant instant()
This returns an instant representing the current instant as defined by the clock.
Note: If scheduler does not support time in nanoseconds the returned Instant
will be limited by milliseconds
@NonNull public static SchedulerClock of(@NonNull reactor.core.scheduler.Scheduler scheduler)
scheduler
- Scheduler
instanceSchedulerClock
@NonNull public static SchedulerClock of(@NonNull reactor.core.scheduler.Scheduler scheduler, @NonNull ZoneId zoneId)
scheduler
- Scheduler
instanceSchedulerClock