@UnstableApi
public interface Clock

Known direct subclasses
FakeClock

Fake Clock implementation that allows to advance the time manually to trigger pending timed messages.

SystemClock

The standard implementation of Clock, an instance of which is available via DEFAULT.


An interface through which system clocks can be read and HandlerWrappers created. The DEFAULT implementation must be used for all non-test cases.

Summary

Constants

default static final Clock

Default Clock to use for all non-test cases.

Public methods

abstract HandlerWrapper

Creates a HandlerWrapper using a specified looper and a specified callback for handling messages.

abstract long

Returns the current time in milliseconds since the Unix Epoch.

abstract long
abstract long

See nanoTime

abstract void

Notifies the clock that the current thread is about to be blocked and won't return until a condition on another thread becomes true.

abstract long

Constants

DEFAULT

default static final Clock DEFAULT

Default Clock to use for all non-test cases.

Public methods

createHandler

abstract HandlerWrapper createHandler(
    Looper looper,
    @Nullable @UnknownInitialization Handler.Callback callback
)

Creates a HandlerWrapper using a specified looper and a specified callback for handling messages.

See also
Handler

currentTimeMillis

abstract long currentTimeMillis()

Returns the current time in milliseconds since the Unix Epoch.

elapsedRealtime

abstract long elapsedRealtime()
See also
elapsedRealtime

nanoTime

abstract long nanoTime()

See nanoTime

onThreadBlocked

abstract void onThreadBlocked()

Notifies the clock that the current thread is about to be blocked and won't return until a condition on another thread becomes true.

Should be a no-op for all non-test cases.

uptimeMillis

abstract long uptimeMillis()
See also
uptimeMillis