public static final class TimeSource.NanoTimeSource extends TimeSource
System.nanoTime().
Epoch time is initialized using TimeSource.CurrentTimeSource, and then
calculated as the elapsed number of nanoseconds as measured by this
implementation.TimeSource.CurrentTimeSource, TimeSource.NanoTimeSource, TimeSource.SimTimeSourceCURRENT_TIME, NANO_TIME| 构造器和说明 |
|---|
NanoTimeSource() |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
convertDelay(TimeUnit fromUnit,
long value,
TimeUnit toUnit)
This method allows using TimeSource with APIs that require providing just plain time intervals,
eg.
|
long |
getEpochTimeNs()
Return Epoch time.
|
long[] |
getTimeAndEpochNs()
Return both the source's time value and the corresponding epoch time
value.
|
long |
getTimeNs()
Return a time value, in nanosecond units.
|
void |
sleep(long ms)
Sleep according to this source's notion of time.
|
get, toStringpublic long getTimeNs()
TimeSourcegetTimeNs 在类中 TimeSourcepublic long getEpochTimeNs()
TimeSourcegetEpochTimeNs 在类中 TimeSourcepublic long[] getTimeAndEpochNs()
TimeSourceTimeSource.getTimeNs().getTimeAndEpochNs 在类中 TimeSourceTimeSource.getTimeNs() and the
second element is TimeSource.getEpochTimeNs().public void sleep(long ms)
throws InterruptedException
TimeSourceTimeSource.SimTimeSource will sleep proportionally shorter, according to its multiplier.sleep 在类中 TimeSourcems - number of milliseconds to sleepInterruptedException - when the current thread is interruptedpublic long convertDelay(TimeUnit fromUnit, long value, TimeUnit toUnit)
TimeSourceObject.wait(long). Values returned by this method are adjusted according to the
time source's notion of time - eg. accelerated time source provided by TimeSource.SimTimeSource
will return intervals that are proportionally shortened by the multiplier.
NOTE: converting small values may significantly affect precision of the returned values due to rounding, especially for accelerated time source, so care should be taken to use time units that result in relatively large values. For example, converting a value of 1 expressed in seconds would result in less precision than converting a value of 1000 expressed in milliseconds.
convertDelay 在类中 TimeSourcefromUnit - source unitvalue - original valuetoUnit - target unitTimeSource.SimTimeSource)Copyright © 2006–2022 The Apache Software Foundation. All rights reserved.