ComplicationText.TimeFormatBuilder

public static final class ComplicationText.TimeFormatBuilder
extends Object

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


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

ComplicationText.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

From class java.lang.Object

Public constructors

ComplicationText.TimeFormatBuilder

ComplicationText.TimeFormatBuilder ()

Public methods

build

ComplicationText build ()

Returns ComplicationText including the formatted time as specified.

Returns
ComplicationText

setFormat

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

ComplicationText.TimeFormatBuilder setStyle (int style)

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

Parameters
style int

Returns
ComplicationText.TimeFormatBuilder this builder for chaining.

setSurroundingText

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

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.