# FakeClock.Builder

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

*** ** * ** ***


```
public final class FakeClock.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock` instances.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder#Builder()()` Creates a new builder for `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock` instances. |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder#build()()` Builds a `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock` instance. |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder#setBootTimeMs(long)(long bootTimeMs)` Sets the time the system was booted since the Unix Epoch, in milliseconds. |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder#setInitialTimeMs(long)(long initialTimeMs)` Sets the initial elapsed time since the boot time, in milliseconds. |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder#setIsAutoAdvancing(boolean)(boolean isAutoAdvancing)` Sets whether the clock should automatically advance the time to the time of the next message that is due to be sent. |
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder#setMaxAutoAdvancingTimeDiffMs(long)(long maxAutoAdvancingTimeDiffMs)` Sets the maximum time difference between two messages that the fake clock will automatically advance. |

## Public constructors

### Builder

```
public Builder()
```

Creates a new builder for `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock` instances.

## Public methods

### build

```
public FakeClock build()
```

Builds a `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock` instance.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock` | The built `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock` instance. |

### setBootTimeMs

```
@CanIgnoreReturnValue
public FakeClock.Builder setBootTimeMs(long bootTimeMs)
```

Sets the time the system was booted since the Unix Epoch, in milliseconds.

The default value is 0.

| Parameters |
|---|---|
| `long bootTimeMs` | The time the system was booted since the Unix Epoch, in milliseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder` | This builder. |

### setInitialTimeMs

```
@CanIgnoreReturnValue
public FakeClock.Builder setInitialTimeMs(long initialTimeMs)
```

Sets the initial elapsed time since the boot time, in milliseconds.

The default value is 0.

| Parameters |
|---|---|
| `long initialTimeMs` | The initial elapsed time since the boot time, in milliseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder` | This builder. |

### setIsAutoAdvancing

```
@CanIgnoreReturnValue
public FakeClock.Builder setIsAutoAdvancing(boolean isAutoAdvancing)
```

Sets whether the clock should automatically advance the time to the time of the next message that is due to be sent.

The default value is false.

| Parameters |
|---|---|
| `boolean isAutoAdvancing` | Whether the clock should automatically advance the time. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder` | This builder. |

### setMaxAutoAdvancingTimeDiffMs

```
@CanIgnoreReturnValue
public FakeClock.Builder setMaxAutoAdvancingTimeDiffMs(long maxAutoAdvancingTimeDiffMs)
```

Sets the maximum time difference between two messages that the fake clock will automatically advance.

The default value is `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock#DEFAULT_MAX_AUTO_ADVANCING_TIME_DIFF_MS()`.

| Parameters |
|---|---|
| `long maxAutoAdvancingTimeDiffMs` | The maximum time difference in milliseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeClock.Builder` | This builder. |