@Implements(value=android.os.SystemClock.class, shadowPicker=ShadowSystemClock.Picker.class) public abstract class ShadowSystemClock extends Object
The shadow API for SystemClock.
The behavior of SystemClock in Robolectric will differ based on the current LooperMode. See ShadowLegacySystemClock and ShadowPausedSystemClock for more details.
| Modifier and Type | Class and Description |
|---|---|
static class |
ShadowSystemClock.Picker |
| Modifier and Type | Field and Description |
|---|---|
protected static boolean |
networkTimeAvailable |
| Constructor and Description |
|---|
ShadowSystemClock() |
| Modifier and Type | Method and Description |
|---|---|
static void |
advanceBy(Duration duration)
A convenience method for advancing the clock via
SystemClock.setCurrentTimeMillis(long) |
static long |
currentTimeMillis()
Implements
System.currentTimeMillis() through ShadowWrangler. |
static long |
nanoTime()
Deprecated.
Don’t call this method directly; instead, use
System.nanoTime(). |
static void |
reset() |
static void |
setNanoTime(long nanoTime)
Sets the value for
System.nanoTime(). |
static void |
setNetworkTimeAvailable(boolean available)
Sets whether network time is available.
|
public static long currentTimeMillis()
Implements System.currentTimeMillis() through ShadowWrangler.
@Deprecated public static long nanoTime()
System.nanoTime().Implements System.nanoTime().
public static void setNanoTime(long nanoTime)
Sets the value for System.nanoTime().
May only be used for LooperMode.Mode.LEGACY. For LooperMode.Mode.PAUSED, nanoTime is calculated based on SystemClock.uptimeMillis() and can’t be set explicitly.
public static void setNetworkTimeAvailable(boolean available)
Sets whether network time is available.
public static void advanceBy(Duration duration)
A convenience method for advancing the clock via SystemClock.setCurrentTimeMillis(long)
duration - The interval by which to advance.public static void reset()