ComplicationText.TimeFormatBuilder

public static final class ComplicationText.TimeFormatBuilder
extends Object

java.lang.Object
   ↳ android.support.wearable.complications.ComplicationText.TimeFormatBuilder


This class is deprecated.
use the Jetpack Wear Watch Face libraries instead.

Builder for a ComplicationText object that displays a text representation of the given time, using the provided format and time zone, within a surrounding string if specified.

Summary

Public constructors

TimeFormatBuilder()

Public methods

ComplicationText build()

Returns ComplicationText including the formatted time as specified.

ComplicationText.TimeFormatBuilder setFormat(String format)

Sets the format that should be applied to the date.

ComplicationText.TimeFormatBuilder setStyle(int style)

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

ComplicationText.TimeFormatBuilder setSurroundingText(CharSequence surroundingText)

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

ComplicationText.TimeFormatBuilder setTimeZone(TimeZone timeZone)

Sets the time zone that will be used for the formatted time.

Inherited methods

Public constructors

TimeFormatBuilder

public TimeFormatBuilder ()

Public methods

build

public ComplicationText build ()

Returns ComplicationText including the formatted time as specified.

Returns
ComplicationText

setFormat

public ComplicationText.TimeFormatBuilder setFormat (String format)

Sets the format that should be applied to the date. This should be a pattern as used by SimpleDateFormat.

Parameters
format String

Returns
ComplicationText.TimeFormatBuilder

setStyle

public ComplicationText.TimeFormatBuilder setStyle (int style)

Sets the style in which the time format part will be displayed. If not set, defaults to ComplicationText.FORMAT_STYLE_DEFAULT, which leaves the formatted date unchanged.

Parameters
style int

Returns
ComplicationText.TimeFormatBuilder this builder for chaining.

setSurroundingText

public ComplicationText.TimeFormatBuilder setSurroundingText (CharSequence surroundingText)

Sets the string 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 ^^.

Parameters
surroundingText CharSequence: string within which the time difference value will be displayed, with ^1 in place of the time difference.

Returns
ComplicationText.TimeFormatBuilder this builder for chaining.

setTimeZone

public ComplicationText.TimeFormatBuilder setTimeZone (TimeZone timeZone)

Sets the time zone that will be used for the formatted time. This is optional - if not set, the system's default time zone will be used.

Parameters
timeZone TimeZone

Returns
ComplicationText.TimeFormatBuilder this builder for chaining.