# TimeFormatComplicationText.Builder

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder "View this page in Java")

<br />

```
class TimeFormatComplicationText.Builder
```

<br />

*** ** * ** ***

A builder for[TimeFormatComplicationText](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText).

## Summary

|                                                                                                                    ### Public constructors                                                                                                                    |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Builder](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder#Builder(kotlin.String))`(format: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` |

|                                                                        ### Public functions                                                                        |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [TimeFormatComplicationText](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText)                 | [build](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder#build())`()` Builds a[TimeFormatComplicationText](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText).                                                                                                          |
| [TimeFormatComplicationText.Builder](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder) | [setStyle](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder#setStyle(androidx.wear.watchface.complications.data.TimeFormatStyle))`(style: `[TimeFormatStyle](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatStyle)`)` Sets the style in which the time format part will be displayed. |
| [TimeFormatComplicationText.Builder](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder) | [setText](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder#setText(kotlin.CharSequence))`(text: `[CharSequence](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)`)` Sets the text within which the time difference will be displayed.                                                                       |
| [TimeFormatComplicationText.Builder](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder) | [setTimeZone](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText.Builder#setTimeZone(android.icu.util.TimeZone))`(timeZone: `[TimeZone](https://developer.android.com/reference/android/icu/util/TimeZone.html)`)` 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)  

```
Builder(format: String)
```  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `format: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | the format in which the time should be displayed. This should be a pattern as used by[java.text.SimpleDateFormat](https://developer.android.com/reference/java/text/SimpleDateFormat.html). |

## Public functions

### build

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

```
fun build(): TimeFormatComplicationText
```

Builds a[TimeFormatComplicationText](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/TimeFormatComplicationText).  

### setStyle

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

```
fun setStyle(style: TimeFormatStyle): TimeFormatComplicationText.Builder
```

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

If not set, defaults to[TimeFormatStyle.DEFAULT](https://developer.android.com/reference/kotlin/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)  

```
fun setText(text: CharSequence): TimeFormatComplicationText.Builder
```

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[ForegroundColorSpan](https://developer.android.com/reference/android/text/style/ForegroundColorSpan.html),[LocaleSpan](https://developer.android.com/reference/android/text/style/LocaleSpan.html),[SubscriptSpan](https://developer.android.com/reference/android/text/style/SubscriptSpan.html),[SuperscriptSpan](https://developer.android.com/reference/android/text/style/SuperscriptSpan.html),[StyleSpan](https://developer.android.com/reference/android/text/style/StyleSpan.html),[StrikethroughSpan](https://developer.android.com/reference/android/text/style/StrikethroughSpan.html),[TypefaceSpan](https://developer.android.com/reference/android/text/style/TypefaceSpan.html)and[UnderlineSpan](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)  

```
fun setTimeZone(timeZone: TimeZone): TimeFormatComplicationText.Builder
```

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