# ComplicationText.TimeDifferenceBuilder

Summary:[Ctors](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder#pubctors)\|[Methods](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder#inhmethods)  

# ComplicationText.TimeDifferenceBuilder

`
public
static
final

class
ComplicationText.TimeDifferenceBuilder
`  
`

extends `[Object](http://developer.android.com/reference/java/lang/Object.html)`


``


`

|---|-------------------------------------------------------------------------------|
| [java.lang.Object](http://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | android.support.wearable.complications.ComplicationText.TimeDifferenceBuilder |

<br />

*** ** * ** ***

<br />

**This class is deprecated.**   
use the[Jetpack Wear Watch Face](https://developer.android.com/jetpack/androidx/releases/wear-watchface)libraries instead.

Builder for a ComplicationText object that displays a text representation of the difference between the given time and the specified time period, within a surrounding string if required.

If the time passed in to[ComplicationText.getText(Context, ComplicationText, long)](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#getText(android.content.Context,%20android.support.wearable.complications.ComplicationText,%20long))on the resulting object is between`referencePeriodStart`and`referencePeriodEnd`, then the text will be "now" (localised to the default locale).

If the time`t`passed in to[ComplicationText.getText(Context, ComplicationText, long)](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#getText(android.content.Context,%20android.support.wearable.complications.ComplicationText,%20long))is before`referencePeriodStart`, then the text shown will represent the time difference between`referencePeriodStart`and`t`.

If the time`t`passed in to[ComplicationText.getText(Context, ComplicationText, long)](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#getText(android.content.Context,%20android.support.wearable.complications.ComplicationText,%20long))is after`referencePeriodEnd`, then the text shown will represent the time difference between`t`and`referencePeriodEnd`.

The way the time difference is represented depends on the`style`. See[ComplicationText.DIFFERENCE_STYLE_SHORT_SINGLE_UNIT](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_SHORT_SINGLE_UNIT),[ComplicationText.DIFFERENCE_STYLE_SHORT_DUAL_UNIT](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_SHORT_DUAL_UNIT),[ComplicationText.DIFFERENCE_STYLE_STOPWATCH](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_STOPWATCH)and[ComplicationText.DIFFERENCE_STYLE_WORDS_SINGLE_UNIT](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_WORDS_SINGLE_UNIT).

## Summary

|                                                                                ### Public constructors                                                                                 ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html#TimeDifferenceBuilder())`() ` |

|                                                                                                                                                                                                                                                                  ### Public methods                                                                                                                                                                                                                                                                  ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[ComplicationText](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html)                                             | ` `[build](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html#build())`() ` Returns[ComplicationText](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html)representing the time difference as specified.                                           |
| ` `[ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | ` `[setMinimumUnit](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html#setMinimumUnit(java.util.concurrent.TimeUnit))`(`[TimeUnit](http://developer.android.com/reference/java/util/concurrent/TimeUnit.html)` minimumUnit) ` Sets the smallest unit that may be shown in the time difference text. |
| ` `[ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | ` `[setReferencePeriodEnd](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html#setReferencePeriodEnd(long))`(long refPeriodEnd) ` Sets the end of the reference period from which the time difference will be calculated.                                                                            |
| ` `[ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | ` `[setReferencePeriodStart](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html#setReferencePeriodStart(long))`(long refPeriodStart) ` Sets the start of the reference period from which the time difference will be calculated.                                                                    |
| ` `[ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | ` `[setShowNowText](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html#setShowNowText(boolean))`(boolean showNowText) ` Sets whether text saying "now" (appropriately localized) should be shown when the given time is within the reference period.                                                |
| ` `[ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | ` `[setStyle](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html#setStyle(int))`(int style) ` Sets the style in which the time difference will be displayed.                                                                                                                                        |
| ` `[ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | ` `[setSurroundingText](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html#setSurroundingText(java.lang.CharSequence))`(`[CharSequence](http://developer.android.com/reference/java/lang/CharSequence.html)` surroundingText) ` Sets the text within which the time difference will be displayed.   |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](http://developer.android.com/reference/java/lang/Object.html)` ` |------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------| | ` `[Object](http://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                               | | ` boolean`                                                                         | ` equals(`[Object](http://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                            | ` finalize() `                                                                            | | ` final `[Class](http://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                            | | ` int`                                                                             | ` hashCode() `                                                                            | | ` final void`                                                                      | ` notify() `                                                                              | | ` final void`                                                                      | ` notifyAll() `                                                                           | | ` `[String](http://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                            | | ` final void`                                                                      | ` wait(long arg0, int arg1) `                                                             | | ` final void`                                                                      | ` wait(long arg0) `                                                                       | | ` final void`                                                                      | ` wait() `                                                                                | ||

## Public constructors

### TimeDifferenceBuilder

```
public TimeDifferenceBuilder ()
```

<br />

<br />

## Public methods

### build

```
public ComplicationText build ()
```

Returns[ComplicationText](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html)representing the time difference as specified.

<br />

|                                                             Returns                                                              ||
|--------------------------------------------------------------------------------------------------------------------------|--------|
| [ComplicationText](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html) | <br /> |

### setMinimumUnit

```
public ComplicationText.TimeDifferenceBuilder 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[TimeUnit.HOURS](http://developer.android.com/reference/java/util/concurrent/TimeUnit.html#HOURS), and the style is[ComplicationText.DIFFERENCE_STYLE_SHORT_SINGLE_UNIT](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_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[ComplicationText.DIFFERENCE_STYLE_SHORT_SINGLE_UNIT](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_SHORT_SINGLE_UNIT), then a minimum unit of[TimeUnit.SECONDS](http://developer.android.com/reference/java/util/concurrent/TimeUnit.html#SECONDS)will have no effect.

<br />

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

|                                                                                   Returns                                                                                    ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
| [ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | <br /> |

### setReferencePeriodEnd

```
public ComplicationText.TimeDifferenceBuilder setReferencePeriodEnd (long refPeriodEnd)
```

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                                                 ||
|----------------|--------------------------------------------------------------------------------------------|
| `refPeriodEnd` | `long`: the end of the reference period, given as UTC milliseconds since the epoch. <br /> |

|                                                                                                 Returns                                                                                                 ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | this builder for chaining. <br /> |

### setReferencePeriodStart

```
public ComplicationText.TimeDifferenceBuilder setReferencePeriodStart (long refPeriodStart)
```

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                                                  ||
|------------------|--------------------------------------------------------------------------------------------|
| `refPeriodStart` | `long`: the end of the reference period, given as UTC milliseconds since the epoch. <br /> |

|                                                                                                 Returns                                                                                                 ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | this builder for chaining. <br /> |

### setShowNowText

```
public ComplicationText.TimeDifferenceBuilder 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[ComplicationText.DIFFERENCE_STYLE_STOPWATCH](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_STOPWATCH).

<br />

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

|                                                                                   Returns                                                                                    ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
| [ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | <br /> |

### setStyle

```
public ComplicationText.TimeDifferenceBuilder setStyle (int style)
```

Sets the style in which the time difference will be displayed. If not set, defaults to[ComplicationText.DIFFERENCE_STYLE_SHORT_DUAL_UNIT](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_SHORT_DUAL_UNIT).

<br />

|      Parameters       ||
|---------|--------------|
| `style` | `int` <br /> |

|                                                                                                 Returns                                                                                                 ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | this builder for chaining. <br /> |

**See also:**

- [ComplicationText.DIFFERENCE_STYLE_SHORT_SINGLE_UNIT](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_SHORT_SINGLE_UNIT)
- [ComplicationText.DIFFERENCE_STYLE_SHORT_DUAL_UNIT](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_SHORT_DUAL_UNIT)
- [ComplicationText.DIFFERENCE_STYLE_STOPWATCH](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_STOPWATCH)
- [ComplicationText.DIFFERENCE_STYLE_WORDS_SINGLE_UNIT](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.html#DIFFERENCE_STYLE_WORDS_SINGLE_UNIT)  

### setSurroundingText

```
public ComplicationText.TimeDifferenceBuilder 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`^^`.

<br />

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

|                                                                                                 Returns                                                                                                 ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|
| [ComplicationText.TimeDifferenceBuilder](https://developer.android.com/reference/android/support/wearable/complications/ComplicationText.TimeDifferenceBuilder.html) | this builder for chaining. <br /> |