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

# TimeDifferenceComplicationText


`
public

final

class
TimeDifferenceComplicationText
`


`

extends Object


`

`


implements

https://developer.android.com/reference/com/google/wear/services/complications/TimeDependentText


`

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

<br />

*** ** * ** ***

Class to generate string representations of time differences.

Time differences greater than `https://developer.android.com/reference/java/lang/Integer#MAX_VALUE` days are not supported.

Note: The preferred way to define dynamic data for complication text is to use a `https://developer.android.com/reference/com/google/wear/services/complications/DynamicComplicationText`. That will be the only supported way to create this type of `https://developer.android.com/reference/com/google/wear/services/complications/ComplicationText` in the future.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText.Builder` Builder for `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText`. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_DUAL_UNIT` Style for time differences shown in a short alpha-numeric style, with up to two significant units included. |
| `int` | `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_SINGLE_UNIT` Style for time differences shown in a short alpha-numeric style, with only the most significant unit included. |
| `int` | `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_SHORT_WORDS_SINGLE_UNIT` Style for time differences shown using (possibly abbreviated) words, with only the most significant unit included, that should fit within the character limit for a short text field. |
| `int` | `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_STOPWATCH` Style for time differences shown in a numeric fashion like a timer. |
| `int` | `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_WORDS_SINGLE_UNIT` Style for time differences shown using (possibly abbreviated) words, with only the most significant unit included. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#equals(java.lang.Object)(Object o) ` |
| ` TimeUnit` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#getMinimumUnit()() ` Returns the minimum `https://developer.android.com/reference/java/util/concurrent/TimeUnit` specified, or `null` if none has been specified. |
| ` long` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#getNextChangeTimeMillis(long)(long fromTime) ` Returns the next time after `fromTime` at which the text may change. |
| ` long` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#getPrecisionMillis()() ` Returns the time precision in milliseconds. |
| ` long` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#getReferencePeriodEndMillis()() ` Returns the end of the reference period, as milliseconds since epoch. |
| ` long` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#getReferencePeriodStartMillis()() ` Returns the start of the reference period, as milliseconds since epoch. |
| ` int` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#getStyle()() ` Returns the time difference style to be used when formatting the text. |
| ` CharSequence` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#getSurroundingText()() ` |
| ` int` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#hashCode()() ` |
| ` boolean` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#isShowNowText()() ` Returns true if text for "now" should be shown when within the reference period. |
| ` boolean` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#returnsSameTextAt(long,%20long)(long firstDateTimeMillis, long secondDateTimeMillis) ` Returns true if the result of the calculation of the current text will be the same for both `firstDateTimeMillis` and `secondDateTimeMillis`. |
| ` String` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#toString()() ` |

| ### 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() ` | ||
| From interface ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDependentText ` |---|---| | ` abstract long` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDependentText#getNextChangeTimeMillis(long)(long fromTime) ` Returns the next time after `fromTime` at which the text may change. | | ` abstract boolean` | ` https://developer.android.com/reference/com/google/wear/services/complications/TimeDependentText#returnsSameTextAt(long,%20long)(long firstDateTimeMillis, long secondDateTimeMillis) ` Returns true if the result of the calculation of the current text will be the same for both `firstDateTimeMillis` and `secondDateTimeMillis`. | ||
| From interface ` https://developer.android.com/reference/com/google/wear/services/complications/ComplicationText ` |---|---| | ` default boolean` | ` https://developer.android.com/reference/com/google/wear/services/complications/ComplicationText#isPlaceholder()() ` Returns if this `ComplicationText` is a placeholder. | ||

## Constants

### STYLE_SHORT_DUAL_UNIT

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

```
public static final int STYLE_SHORT_DUAL_UNIT
```

Style for time differences shown in a short alpha-numeric style, with up to two significant
units included.

For time difference `t`:

If `t < 1 hour`, the value will be shown as a number of minutes, such as `2m`
for 2 minutes. Seconds are not displayed.

If `1 hour <= t < 1 day`, the value will be shown as hours and minutes, such as
`4h 2m` for 4 hours and 2 minutes.

If `1 day <= t < 10 days`, the value will be shown as days and hours, such as `3d 4h` for 3 days 4 hours.

If `10 days <= t`, the value will be shown as a number of days, such as `13d`
for 13 days.

The characters used will be localised to match the default locale. If the representation
of the time difference with two units would be too long in the default locale, just a single
unit may be shown instead.

<br />

Constant Value:

3
(0x00000003)


### STYLE_SHORT_SINGLE_UNIT

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

```
public static final int STYLE_SHORT_SINGLE_UNIT
```

Style for time differences shown in a short alpha-numeric style, with only the most
significant unit included.

For time difference `t`:

If `t < 1 hour`, the value will be shown as a number of minutes, such as `2m`
for 2 minutes. Seconds are not displayed.

If `1 hour <= t < 1 day`, the value will be shown as a number of hours, such as
`4h` for 4 hours.

If `1 days <= t`, the value will be shown as a number of days, such as `13d`
for 13 days.

The characters used will be localised to match the default locale.

<br />

Constant Value:

2
(0x00000002)


### STYLE_SHORT_WORDS_SINGLE_UNIT

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

```
public static final int STYLE_SHORT_WORDS_SINGLE_UNIT
```

Style for time differences shown using (possibly abbreviated) words, with only the most
significant unit included, that should fit within the character limit for a short text field.

The output will be the same as for `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_WORDS_SINGLE_UNIT`, except that if the
text does not fit into the seven character limit then a shorter form will be used instead,
e.g. "1356d" instead of "1356 days".

<br />

Constant Value:

5
(0x00000005)


### STYLE_STOPWATCH

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

```
public static final int STYLE_STOPWATCH
```

Style for time differences shown in a numeric fashion like a timer.

For time difference `t`:

If `t < 1 hour`, the value will be shown as minutes and seconds, such as `02:35` for 2 minutes and 35 seconds.

If `1 hour <= t < 1 day`, the value will be shown as hours and minutes, such as
`4:02` for 4 hours and 2 minutes, or as `12:02` for 12 hours and 2 minutes.

If `1 day <= t < 10 days`, the value will be shown as days and hours, such as `3d 4h` for 3 days 4 hours.

If `10 days <= t`, the value will be shown as just days, such as `13d` for 13
days.

The characters used will be localised to match the default locale.

<br />

Constant Value:

1
(0x00000001)


### STYLE_WORDS_SINGLE_UNIT

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

```
public static final int STYLE_WORDS_SINGLE_UNIT
```

Style for time differences shown using (possibly abbreviated) words, with only the most
significant unit included.

For time difference `t`:

If `t < 1 hour`, the value will be shown as a number of minutes, such as `1
min` for 1 minute or `2 mins` for 2 minutes. Seconds are not displayed.

If `1 hour <= t < 1 day`, the value will be shown as a number of hours, such as
`1 hour` for 1 hour or `4 hours` for 4 hours.

If `1 days <= t`, the value will be shown as a number of days, such as `1 day`
for 1 day or `13 days` for 13 days.

The words used will be localised to match the default locale.

<br />

Constant Value:

4
(0x00000004)


## Public methods

### equals

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

```
public boolean equals (Object o)
```

<br />

<br />

| Parameters ||
|---|---|
| `o` | `Object` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### getMinimumUnit

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

```
public TimeUnit getMinimumUnit ()
```

Returns the minimum `https://developer.android.com/reference/java/util/concurrent/TimeUnit` specified, or `null` if none has been specified.

<br />

| Returns ||
|---|---|
| `TimeUnit` | <br /> |

### getNextChangeTimeMillis

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

```
public long getNextChangeTimeMillis (long fromTime)
```

Returns the next time after `fromTime` at which the text may change.

<br />

| Parameters ||
|---|---|
| `fromTime` | `long` <br /> |

| Returns ||
|---|---|
| `long` | <br /> |

### getPrecisionMillis

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

```
public long getPrecisionMillis ()
```

Returns the time precision in milliseconds.

The result is max(`https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#getMinimumUnit()`, 1000) for `https://developer.android.com/reference/com/google/wear/services/complications/TimeDifferenceComplicationText#STYLE_STOPWATCH` or 1000
otherwise.

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### getReferencePeriodEndMillis

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

```
public long getReferencePeriodEndMillis ()
```

Returns the end of the reference period, as milliseconds since epoch.

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### getReferencePeriodStartMillis

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

```
public long getReferencePeriodStartMillis ()
```

Returns the start of the reference period, as milliseconds since epoch.

<br />

| Returns ||
|---|---|
| `long` | <br /> |

### getStyle

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

```
public int getStyle ()
```

Returns the time difference style to be used when formatting the text.

<br />

| Returns ||
|---|---|
| `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` |

### getSurroundingText

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

```
public CharSequence getSurroundingText ()
```

<br />

<br />

| Returns ||
|---|---|
| `CharSequence` | <br /> |

### hashCode

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

```
public int hashCode ()
```

<br />

<br />

| Returns ||
|---|---|
| `int` | <br /> |

### isShowNowText

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

```
public boolean isShowNowText ()
```

Returns true if text for "now" should be shown when within the reference period.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### returnsSameTextAt

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

```
public boolean returnsSameTextAt (long firstDateTimeMillis, 
                long secondDateTimeMillis)
```

Returns true if the result of the calculation of the current text will be the same for both
`firstDateTimeMillis` and `secondDateTimeMillis`.

<br />

| Parameters ||
|---|---|
| `firstDateTimeMillis` | `long` <br /> |
| `secondDateTimeMillis` | `long` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### toString

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

```
public String toString ()
```

<br />

<br />

| Returns ||
|---|---|
| `String` | <br /> |