# SystemClock

# SystemClock

Artifact:[androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/common/util/SystemClock.java+class:androidx.media3.common.util.SystemClock)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/common/util/SystemClock "View this page in Java")

<br />

```
@UnstableApi
class SystemClock : Clock
```

<br />

*** ** * ** ***

The standard implementation of[Clock](https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock), an instance of which is available via[DEFAULT](https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock#DEFAULT()).

## Summary

|                                               ### Protected constructors                                                |
|-------------------------------------------------------------------------------------------------------------------------|
| [SystemClock](https://developer.android.com/reference/kotlin/androidx/media3/common/util/SystemClock#SystemClock())`()` |

|                                              ### Public functions                                              |
|----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [HandlerWrapper](https://developer.android.com/reference/kotlin/androidx/media3/common/util/HandlerWrapper)`!` | [createHandler](https://developer.android.com/reference/kotlin/androidx/media3/common/util/SystemClock#createHandler(android.os.Looper,android.os.Handler.Callback))`(` ` looper: `[Looper](https://developer.android.com/reference/android/os/Looper.html)`!,` ` @`[UnknownInitialization](https://checkerframework.org/api/org/checkerframework/checker/initialization/qual/UnknownInitialization.html)` callback: @`[UnknownInitialization](https://checkerframework.org/api/org/checkerframework/checker/initialization/qual/UnknownInitialization.html)` `[Handler.Callback](https://developer.android.com/reference/android/os/Handler.Callback.html)`?` `)` Creates a[HandlerWrapper](https://developer.android.com/reference/kotlin/androidx/media3/common/util/HandlerWrapper)using a specified looper and a specified callback for handling messages. |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                  | [currentTimeMillis](https://developer.android.com/reference/kotlin/androidx/media3/common/util/SystemClock#currentTimeMillis())`()` Returns the current time in milliseconds since the Unix Epoch.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                  | [elapsedRealtime](https://developer.android.com/reference/kotlin/androidx/media3/common/util/SystemClock#elapsedRealtime())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                  | [nanoTime](https://developer.android.com/reference/kotlin/androidx/media3/common/util/SystemClock#nanoTime())`()` See[nanoTime](https://developer.android.com/reference/java/lang/System.html#nanoTime())                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                  | [onThreadBlocked](https://developer.android.com/reference/kotlin/androidx/media3/common/util/SystemClock#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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                  | [uptimeMillis](https://developer.android.com/reference/kotlin/androidx/media3/common/util/SystemClock#uptimeMillis())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

|                                                                                                                                                                                                                                                                                                                                                                                                  ### Inherited Constants                                                                                                                                                                                                                                                                                                                                                                                                  |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.media3.common.util.Clock](https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock) |------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `const `[Clock](https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock)`!` | [DEFAULT](https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock#DEFAULT()) Default[Clock](https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock)to use for all non-test cases. | |

## Protected constructors

### SystemClock

```
protected SystemClock()
```  

## Public functions

### createHandler

```
fun createHandler(
    looper: Looper!,
    @UnknownInitialization callback: @UnknownInitialization Handler.Callback?
): HandlerWrapper!
```

Creates a[HandlerWrapper](https://developer.android.com/reference/kotlin/androidx/media3/common/util/HandlerWrapper)using a specified looper and a specified callback for handling messages.  

|                                                              See also                                                              |
|------------------------------------------------------------------------------------------------------------------------------------|---|
| [Handler](https://developer.android.com/reference/android/os/Handler.html#Handler(android.os.Looper, android.os.Handler.Callback)) |   |

### currentTimeMillis

```
fun currentTimeMillis(): Long
```

Returns the current time in milliseconds since the Unix Epoch.  

|                                                See also                                                |
|--------------------------------------------------------------------------------------------------------|---|
| [currentTimeMillis](https://developer.android.com/reference/java/lang/System.html#currentTimeMillis()) |   |

### elapsedRealtime

```
fun elapsedRealtime(): Long
```  

|                                                 See also                                                 |
|----------------------------------------------------------------------------------------------------------|---|
| [elapsedRealtime](https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()) |   |

### nanoTime

```
fun nanoTime(): Long
```

See[nanoTime](https://developer.android.com/reference/java/lang/System.html#nanoTime())  

### onThreadBlocked

```
fun onThreadBlocked(): Unit
```

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

```
fun uptimeMillis(): Long
```  

|                                              See also                                              |
|----------------------------------------------------------------------------------------------------|---|
| [uptimeMillis](https://developer.android.com/reference/android/os/SystemClock.html#uptimeMillis()) |   |