public interface SimonClock
SYSTEM
is used to match System timers,
but different implementation can be used to provide different time for Manager
.
This also allows easier testing without sleeping.Modifier and Type | Field and Description |
---|---|
static SimonClock |
CPU
Clock implementation measuring CPU time.
|
static long |
MILLIS_IN_SECOND
Number of milliseconds in one second.
|
static long |
NANOS_IN_MILLIS
Number of nanoseconds in one millisecond.
|
static long |
NANOS_IN_SECOND
Number of nanoseconds in one second.
|
static SimonClock |
SYSTEM
Default implementation using
System.currentTimeMillis() and System.nanoTime() . |
Modifier and Type | Method and Description |
---|---|
long |
millisForNano(long nanos)
Converts nano timer value into millis timestamp compatible with
milliTime() without actually
using the timer. |
long |
milliTime()
Gets current time in milliseconds.
|
long |
nanoTime()
Gets current time in nanoseconds.
|
static final long MILLIS_IN_SECOND
static final long NANOS_IN_MILLIS
static final long NANOS_IN_SECOND
static final SimonClock SYSTEM
System.currentTimeMillis()
and System.nanoTime()
.static final SimonClock CPU
long nanoTime()
long milliTime()
long millisForNano(long nanos)
milliTime()
without actually
using the timer. Method does not just divide nanos by one million, but also works with remembered
values for milli- and nano-timers at one particular moment.nanos
- nano timer valueCopyright © 2019. All rights reserved.