Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#pubctors) \| [Methods](https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#inhmethods)

# TimeDifferenceComplicationText.Builder


`
public
static
final

class
TimeDifferenceComplicationText.Builder
`


`

extends Object


`

`


`

|---|---|
| java.lang.Object ||
| ↳ | com.google.wear.services.complications.TimeDifferenceComplicationText.Builder |

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#Builder()() ` |
| ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#Builder(long,%20long)(long referencePeriodStartMillis, long referencePeriodEndMillis) ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#build()() ` Builds a `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText`. |
| ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#setMinimumUnit(java.util.concurrent.TimeUnit)(TimeUnit minimumUnit) ` Sets the smallest unit that may be shown in the time difference text. |
| ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#setReferencePeriodEndMillis(long)(long refPeriodEndMillis) ` Sets the end of the reference period from which the time difference will be calculated. |
| ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#setReferencePeriodStartMillis(long)(long refPeriodStartMillis) ` Sets the start of the reference period from which the time difference will be calculated. |
| ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#setShowNowText(boolean)(boolean showNowText) ` Sets whether text saying "now" (appropriately localized) should be shown when the given time is within the reference period. |
| ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#setStyle(int)(int style) ` Sets the style in which the time difference will be displayed. |
| ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder#setSurroundingText(java.lang.CharSequence)(CharSequence surroundingText) ` Sets the text within which the time difference will be displayed. |

| ### Inherited methods |
|---|---|
| From class ` java.lang.Object ` |---|---| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class<?>` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` String` | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||

## Public constructors

### Builder

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder ()
```

<br />

<br />

### Builder

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder (long referencePeriodStartMillis, 
                long referencePeriodEndMillis)
```

<br />

<br />

| Parameters ||
|---|---|
| `referencePeriodStartMillis` | `long`: The start of the reference period (in milliseconds since the epoch) from which the time difference will be calculated. <br /> |
| `referencePeriodEndMillis` | `long`: The end of the reference period (in milliseconds since the epoch) from which the time difference will be calculated. <br /> |

## Public methods

### build

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TimeDifferenceComplicationText build ()
```

Builds a `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText` | <br /> |

### setMinimumUnit

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TimeDifferenceComplicationText.Builder setMinimumUnit (TimeUnit minimumUnit)
```

Sets the smallest unit that may be shown in the time difference text. If specified, units
smaller than this minimum will not be included.

For example, if this is set to `https://developer.android.com/reference/java/util/concurrent/TimeUnit#HOURS`, and the style is `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_SINGLE_UNIT` then "12d" or "5h" would be shown
as normal, but "35m" would be shown as "1h".

This is optional. If not specified, or if set to null, the style will determine the
smallest unit that will be shown.

If the specified minimum is smaller than the smallest unit supported by the style,
then the minimum will be ignored. For example, if the style is `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_SINGLE_UNIT`, then a minimum unit of `https://developer.android.com/reference/java/util/concurrent/TimeUnit#SECONDS` will have no effect.

<br />

| Parameters ||
|---|---|
| `minimumUnit` | `TimeUnit` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | <br /> |

### setReferencePeriodEndMillis

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TimeDifferenceComplicationText.Builder setReferencePeriodEndMillis (long refPeriodEndMillis)
```

Sets the end of the reference period from which the time difference will be calculated.
Defaults to `Long.MAX_VALUE`, effectively making the period unbounded at the end.

<br />

| Parameters ||
|---|---|
| `refPeriodEndMillis` | `long`: the end of the reference period, given as UTC milliseconds since the epoch. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | this builder for chaining. <br /> |

### setReferencePeriodStartMillis

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TimeDifferenceComplicationText.Builder setReferencePeriodStartMillis (long refPeriodStartMillis)
```

Sets the start of the reference period from which the time difference will be calculated.
Defaults to 0, effectively making the period unbounded at the start.

<br />

| Parameters ||
|---|---|
| `refPeriodStartMillis` | `long`: the end of the reference period, given as UTC milliseconds since the epoch. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | this builder for chaining. <br /> |

### setShowNowText

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TimeDifferenceComplicationText.Builder setShowNowText (boolean showNowText)
```

Sets whether text saying "now" (appropriately localized) should be shown when the given
time is within the reference period. If `showNowText` is false, then text
representing zero (e.g. "0 mins" or "00:00") will be shown instead.

The default is true for all styles except for `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_STOPWATCH`.

<br />

| Parameters ||
|---|---|
| `showNowText` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | <br /> |

### setStyle

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TimeDifferenceComplicationText.Builder setStyle (int style)
```

Sets the style in which the time difference will be displayed. If not set, defaults to
`https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_DUAL_UNIT`.

<br />

| Parameters ||
|---|---|
| `style` | `int`: Value is one of the following: - `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_STOPWATCH` - `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_SINGLE_UNIT` - `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_DUAL_UNIT` - `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_WORDS_SINGLE_UNIT` - `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_WORDS_SINGLE_UNIT` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | this builder for chaining. <br /> |

**See also:**

- `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_SINGLE_UNIT`
- `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_DUAL_UNIT`
- `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_STOPWATCH`
- `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_WORDS_SINGLE_UNIT`

### setSurroundingText

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public TimeDifferenceComplicationText.Builder setSurroundingText (CharSequence surroundingText)
```

Sets the text within which the time difference will be displayed. This is optional.

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

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

If the text contains spans, some of them may not be rendered by the complication drawable. Supported spans
are `https://developer.android.com/reference/android/text/style/ForegroundColorSpan`, `https://developer.android.com/reference/android/text/style/LocaleSpan`, `https://developer.android.com/reference/android/text/style/SubscriptSpan`, `https://developer.android.com/reference/android/text/style/SuperscriptSpan`, `https://developer.android.com/reference/android/text/style/StyleSpan`, `https://developer.android.com/reference/android/text/style/StrikethroughSpan`, `https://developer.android.com/reference/android/text/style/TypefaceSpan` and
`https://developer.android.com/reference/android/text/style/UnderlineSpan`.

<br />

| Parameters ||
|---|---|
| `surroundingText` | `CharSequence`: text within which the time difference value will be displayed, with `^1` in place of the time difference. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` | this builder for chaining. <br /> |