public class SettableSystemClock extends Object implements SettableClock
Clock.SYSTEM,
but any time you set a "corrected" value via setCurrentTimeMillis(long),
will record a correction and work off that value instead.
This Clock assumes that once a currentTimeMilliseconds is
passed in as the "correct" value, the Clock.SYSTEM Clock will
continue to process at the correct or near-correct pace.
If it doesn't, the currentTimeMilliseconds may need to be
set again periodically to the correct value.| Constructor and Description |
|---|
SettableSystemClock() |
| Modifier and Type | Method and Description |
|---|---|
long |
currentTimeMillis()
Returns the milliseconds UTC since the epoch.
|
void |
schedule(ScheduledExecutorService scheduledExecutorService,
Runnable runnable,
long millisecondsInTheFutureToSchedule)
Schedules runnable the specified millisecondsInTheFutureToSchedule
using scheduledExecutorService.
|
void |
setCurrentTimeMillis(long correctCurrentTimeMillis)
Sets the milliseconds UTC since the epoch to the specified value.
|
public long currentTimeMillis()
currentTimeMillis in interface Clockpublic void schedule(ScheduledExecutorService scheduledExecutorService, Runnable runnable, long millisecondsInTheFutureToSchedule)
schedule in interface ClockscheduledExecutorService - the ScheduledExecutorService to submit the runnable torunnable - the runnable to execute on a schedulemillisecondsInTheFutureToSchedule - the schedule of milliseconds in the future,
approximating when the runnable should run.public void setCurrentTimeMillis(long correctCurrentTimeMillis)
setCurrentTimeMillis in interface SettableClockcorrectCurrentTimeMillis - this clock's currentTimeMillis in UTC since the epoch.Copyright © 2021 HERE Europe B.V. All Rights Reserved.