@ThreadSafe public final class TestClock extends io.opencensus.common.Clock
Clock that allows the time to be set for testing.| Modifier and Type | Method and Description |
|---|---|
void |
advanceTime(io.opencensus.common.Duration duration)
Advances the time by a duration.
|
static TestClock |
create()
Creates a clock initialized to a constant non-zero time.
|
static TestClock |
create(io.opencensus.common.Timestamp time)
Creates a clock with the given time.
|
io.opencensus.common.Timestamp |
now() |
long |
nowNanos() |
void |
setTime(io.opencensus.common.Timestamp time)
Sets the time.
|
public static TestClock create()
Timestamp.create(0, 0) is not
a good default, because it represents an invalid time.public static TestClock create(io.opencensus.common.Timestamp time)
time - the initial time.TestClock with the given time.public void setTime(io.opencensus.common.Timestamp time)
time - the new time.public void advanceTime(io.opencensus.common.Duration duration)
duration - the increase in time.public io.opencensus.common.Timestamp now()
now in class io.opencensus.common.Clockpublic long nowNanos()
nowNanos in class io.opencensus.common.Clock