public class SetTimeProvider extends AtomicLong implements TimeProvider
Created by Peter Lawrey on 10/03/16.
| Constructor and Description |
|---|
SetTimeProvider()
Create a time provider which start as 0
|
SetTimeProvider(Instant instant)
Create a time provider which starts at a given Instant
|
SetTimeProvider(long initialNanos)
Create a time provider which starts at a specific time
|
SetTimeProvider(String timestamp)
Create a timeprovider which starts a time specified as ISO8601 format
|
| Modifier and Type | Method and Description |
|---|---|
SetTimeProvider |
advanceMicros(long micros)
Advances time in microseconds.
|
SetTimeProvider |
advanceMillis(long millis)
Advances time in milliseconds.
|
SetTimeProvider |
advanceNanos(long nanos)
Advances time in nanoseconds.
|
SetTimeProvider |
autoIncrement(long autoIncrement,
TimeUnit timeUnit) |
long |
currentTime(TimeUnit unit) |
long |
currentTimeMicros() |
void |
currentTimeMicros(long micros)
Set the current time in microseconds.
|
long |
currentTimeMillis() |
void |
currentTimeMillis(long millis)
Set the current time in milliseconds.
|
long |
currentTimeNanos() |
void |
currentTimeNanos(long nanos)
Set the current time in nanoseconds.
|
SetTimeProvider |
now()
Create a time provider which starts now
|
String |
toString() |
accumulateAndGet, addAndGet, compareAndSet, decrementAndGet, doubleValue, floatValue, get, getAndAccumulate, getAndAdd, getAndDecrement, getAndIncrement, getAndSet, getAndUpdate, incrementAndGet, intValue, lazySet, longValue, set, updateAndGet, weakCompareAndSetbyteValue, shortValuepublic SetTimeProvider()
public SetTimeProvider(long initialNanos)
initialNanos - in nano-seconds since epochpublic SetTimeProvider(String timestamp)
timestamp - to startpublic SetTimeProvider(Instant instant)
instant - to startpublic SetTimeProvider now()
public SetTimeProvider autoIncrement(long autoIncrement, TimeUnit timeUnit)
public void currentTimeMillis(long millis)
throws IllegalArgumentException
millis - New time value in milliseconds since the epoch. May not be less than the previous value.IllegalArgumentException - if time is set backwardspublic long currentTimeMillis()
currentTimeMillis in interface TimeProviderpublic void currentTimeMicros(long micros)
throws IllegalArgumentException
micros - New time value in microseconds since the epoch. May not be less than the previous value.IllegalArgumentException - if time is set backwardspublic long currentTimeMicros()
currentTimeMicros in interface TimeProviderpublic void currentTimeNanos(long nanos)
throws IllegalArgumentException
nanos - New time value in nanoseconds since the epoch. May not be less than the previous value.IllegalArgumentException - if time is set backwardspublic long currentTimeNanos()
currentTimeNanos in interface TimeProviderpublic long currentTime(TimeUnit unit)
currentTime in interface TimeProviderpublic SetTimeProvider advanceMillis(long millis)
millis - duration.public SetTimeProvider advanceMicros(long micros)
micros - duration.public SetTimeProvider advanceNanos(long nanos)
nanos - duration.public String toString()
toString in class AtomicLongCopyright © 2023. All rights reserved.