Build 1.0_r1(from source)

android.os
Class SystemClock

java.lang.Object
  extended by android.os.SystemClock

public final class SystemClock
extends Object

Core timekeeping facilities.

Three different clocks are available, and they should not be confused:

There are several mechanisms for controlling the timing of events:


Method Summary
static long currentThreadTimeMillis()
          Returns milliseconds running in the current thread.
static long elapsedRealtime()
          Returns milliseconds since boot, including time spent in sleep.
static boolean setCurrentTimeMillis(long millis)
          Sets the current wall time, in milliseconds.
static void sleep(long ms)
          Waits a given number of milliseconds (of uptimeMillis) before returning.
static long uptimeMillis()
          Returns milliseconds since boot, not counting time spent in deep sleep.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sleep

public static void sleep(long ms)
Waits a given number of milliseconds (of uptimeMillis) before returning. Similar to Thread.sleep(long), but does not throw InterruptedException; Thread.interrupt() events are deferred until the next interruptible operation. Does not return until at least the specified number of milliseconds has elapsed.

Parameters:
ms - to sleep before returning, in milliseconds of uptime.

setCurrentTimeMillis

public static boolean setCurrentTimeMillis(long millis)
Sets the current wall time, in milliseconds. Requires the calling process to have appropriate permissions.

Returns:
if the clock was successfully set to the specified time.

uptimeMillis

public static long uptimeMillis()
Returns milliseconds since boot, not counting time spent in deep sleep. Note: This value may get reset occasionally (before it would otherwise wrap around).

Returns:
milliseconds of non-sleep uptime since boot.

elapsedRealtime

public static long elapsedRealtime()
Returns milliseconds since boot, including time spent in sleep.

Returns:
elapsed milliseconds since boot.

currentThreadTimeMillis

public static long currentThreadTimeMillis()
Returns milliseconds running in the current thread.

Returns:
elapsed milliseconds in the thread

Build 1.0_r1(from source)

Please submit a feedback, bug or feature