# TimerSpan

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/model/TimerSpan.java+class:androidx.car.app.model.TimerSpan) Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.8.0)

*** ** * ** ***


```
@ExperimentalCarApi
@CarProtocol
public final class TimerSpan extends CarSpan
```

<br />

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||||
| ↳ | [android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html) |||
|   | ↳ | [androidx.car.app.model.CarSpan](https://developer.android.com/reference/androidx/car/app/model/CarSpan) ||
|   |   | ↳ | [androidx.car.app.model.TimerSpan](https://developer.android.com/reference/androidx/car/app/model/TimerSpan) |

*** ** * ** ***

A `https://developer.android.com/reference/androidx/car/app/model/CarSpan` that represents a timer.

This span can be used within text to display a live-updating timer. The timer will count up from the provided start time, which is based on the elapsed real time since device boot, as provided by `SystemClock.elapsedRealtime()`.

For example, a `https://developer.android.com/reference/androidx/car/app/model/TimerSpan` can be used in a `https://developer.android.com/reference/androidx/car/app/model/CarText` to show how much time has passed since a certain event. The exact rendering of the timer is dependent on the car screen.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/CarSpan` |   |

## Summary

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/TimerSpan` | `https://developer.android.com/reference/androidx/car/app/model/TimerSpan#create(long)(long elapsedRealtimeMillis)` Creates a `https://developer.android.com/reference/androidx/car/app/model/TimerSpan` from a start time in elapsed real time since device boot. |
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/TimerSpan#equals(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html other)` |
| `long` | `https://developer.android.com/reference/androidx/car/app/model/TimerSpan#getElapsedRealtimeMillis()()` Returns the start time of the timer in milliseconds since device boot. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/TimerSpan#hashCode()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/TimerSpan#toString()()` |

| ### Inherited methods |
|---|
| From [androidx.car.app.model.CarSpan](https://developer.android.com/reference/androidx/car/app/model/CarSpan) |---|---| | `void` | `https://developer.android.com/reference/androidx/car/app/model/CarSpan#updateDrawState(android.text.TextPaint)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/text/TextPaint.html tp)` | |
| From [android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle.html) |---|---| | `https://developer.android.com/reference/android/text/style/CharacterStyle.html` | `https://developer.android.com/reference/android/text/style/CharacterStyle.html#getUnderlying()()` | | `abstract void` | `https://developer.android.com/reference/android/text/style/CharacterStyle.html#updateDrawState(android.text.TextPaint)(https://developer.android.com/reference/android/text/TextPaint.html p)` | | `static https://developer.android.com/reference/android/text/style/CharacterStyle.html` | `https://developer.android.com/reference/android/text/style/CharacterStyle.html#wrap(android.text.style.CharacterStyle)(https://developer.android.com/reference/android/text/style/CharacterStyle.html cs)` | |

## Public methods

### create

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.8.0)

```
public static @NonNull TimerSpan create(long elapsedRealtimeMillis)
```

Creates a `https://developer.android.com/reference/androidx/car/app/model/TimerSpan` from a start time in elapsed real time since device boot.

The timer will count up if the provided `elapsedRealtimeMillis` is in the past relative to the current `SystemClock.elapsedRealtime()`, and will count down if it is in the future.

| Parameters |
|---|---|
| `long elapsedRealtimeMillis` | the start time in milliseconds using `SystemClock .elapsedRealtime()`. |

### equals

```
public boolean equals(@Nullable Object other)
```

### getElapsedRealtimeMillis

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.8.0)

```
public long getElapsedRealtimeMillis()
```

Returns the start time of the timer in milliseconds since device boot.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```