public class Time extends Object
This class implements time simulation support. When time simulation is enabled, methods on this class will use fixed time. When time simulation is disabled, methods will pass through to relevant java.lang.System/java.lang.Thread calls. Methods using units higher than nanoseconds will pass through to System.currentTimeMillis(). Methods supporting nanoseconds will pass through to System.nanoTime().
Modifier and Type | Class and Description |
---|---|
static class |
Time.SimulatedTime |
Modifier and Type | Field and Description |
---|---|
static org.slf4j.Logger |
LOG |
Constructor and Description |
---|
Time() |
Modifier and Type | Method and Description |
---|---|
static void |
advanceTime(long ms) |
static void |
advanceTimeNanos(long nanos) |
static void |
advanceTimeSecs(long secs) |
static long |
currentTimeMillis() |
static int |
currentTimeSecs() |
static long |
deltaMs(long timeInMilliseconds) |
static int |
deltaSecs(int timeInSeconds) |
static boolean |
isSimulating() |
static boolean |
isThreadWaiting(Thread t) |
static long |
millisToNanos(long millis) |
static long |
nanosToMillis(long nanos) |
static long |
nanoTime() |
static long |
secsToMillis(int secs) |
static long |
secsToMillisLong(double secs) |
static void |
sleep(long ms) |
static void |
sleepNanos(long nanos) |
static void |
sleepSecs(long secs) |
static void |
sleepUntil(long targetTimeMs) |
static void |
sleepUntilNanos(long targetTimeNanos) |
static void |
startSimulating()
Deprecated.
|
static void |
stopSimulating()
Deprecated.
|
@Deprecated public static void startSimulating()
@Deprecated public static void stopSimulating()
public static boolean isSimulating()
public static void sleepUntil(long targetTimeMs) throws InterruptedException
InterruptedException
public static void sleepUntilNanos(long targetTimeNanos) throws InterruptedException
InterruptedException
public static void sleep(long ms) throws InterruptedException
InterruptedException
public static void sleepNanos(long nanos) throws InterruptedException
InterruptedException
public static void sleepSecs(long secs) throws InterruptedException
InterruptedException
public static long nanoTime()
public static long currentTimeMillis()
public static long nanosToMillis(long nanos)
public static long millisToNanos(long millis)
public static long secsToMillis(int secs)
public static long secsToMillisLong(double secs)
public static int currentTimeSecs()
public static int deltaSecs(int timeInSeconds)
public static long deltaMs(long timeInMilliseconds)
public static void advanceTime(long ms)
public static void advanceTimeNanos(long nanos)
public static void advanceTimeSecs(long secs)
public static boolean isThreadWaiting(Thread t)
Copyright © 2019 The Apache Software Foundation. All Rights Reserved.