# TimeFormatComplicationText.Builder

Artifact: [androidx.wear.watchface:watchface-complications-data](https://developer.android.com/jetpack/androidx/releases/wear-watchface) [View Source](https://cs.android.com/search?q=file:androidx/wear/watchface/complications/data/Text.kt+class:androidx.wear.watchface.complications.data.TimeFormatComplicationText.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0)

*** ** * ** ***


```
public final class TimeFormatComplicationText.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder#Builder(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html format)` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder#build()()` Builds a `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder#setStyle(androidx.wear.watchface.complications.data.TimeFormatStyle)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatStyle style)` Sets the style in which the time format part will be displayed. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder#setText(kotlin.CharSequence)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html text)` Sets the text within which the time difference will be displayed. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder#setTimeZone(android.icu.util.TimeZone)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/icu/util/TimeZone.html timeZone)` Sets the time zone that will be used for the formatted time. |

## Public constructors

### Builder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0)

```
public Builder(@NonNull String format)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html format` | the format in which the time should be displayed. This should be a pattern as used by `https://developer.android.com/reference/java/text/SimpleDateFormat.html`. |

## Public methods

### build

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0)

```
public final @NonNull TimeFormatComplicationText build()
```

Builds a `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText`.

### setStyle

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0)

```
public final @NonNull TimeFormatComplicationText.Builder setStyle(@NonNull TimeFormatStyle style)
```

Sets the style in which the time format part will be displayed.

If not set, defaults to `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatStyle#DEFAULT`, which leaves the formatted date unchanged.

### setText

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0)

```
public final @NonNull TimeFormatComplicationText.Builder setText(@NonNull CharSequence text)
```

Sets the text within which the time difference will be displayed.

Within the text, `^1` will be replaced with the time difference, so for example to show a result like `"2 mins: meeting"` the text would be `"^1: meeting"`

To use the `^` character within the text, escape it as `^^`.

The text may contain spans, but ther watch face is not required to respect them.

The allowed spans are `https://developer.android.com/reference/android/text/style/ForegroundColorSpan.html`, `https://developer.android.com/reference/android/text/style/LocaleSpan.html`, `https://developer.android.com/reference/android/text/style/SubscriptSpan.html`, `https://developer.android.com/reference/android/text/style/SuperscriptSpan.html`, `https://developer.android.com/reference/android/text/style/StyleSpan.html`, `https://developer.android.com/reference/android/text/style/StrikethroughSpan.html`, `https://developer.android.com/reference/android/text/style/TypefaceSpan.html` and `https://developer.android.com/reference/android/text/style/UnderlineSpan.html`.

### setTimeZone

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0)

```
public final @NonNull TimeFormatComplicationText.Builder setTimeZone(@NonNull TimeZone timeZone)
```

Sets the time zone that will be used for the formatted time. If not set, the system's default time zone will be used.