Class SchedulerClock

java.lang.Object
java.time.Clock
com.couchbase.client.core.scheduler.SchedulerClock

public class SchedulerClock extends Clock
Clock adapter around 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));
     
 

Since:
3.1.4
Author:
Oleh Dokuka, Peter Royal