TimeFormatComplicationText.Builder

public final class TimeFormatComplicationText.Builder


A builder for TimeFormatComplicationText.

Summary

Public constructors

Public methods

final @NonNull TimeFormatComplicationText

Builds a TimeFormatComplicationText.

final @NonNull TimeFormatComplicationText.Builder

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

final @NonNull TimeFormatComplicationText.Builder

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

final @NonNull TimeFormatComplicationText.Builder

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

Public constructors

Builder

public final Builder(@NonNull String format)
Parameters
@NonNull String format

the format in which the time should be displayed. This should be a pattern as used by java.text.SimpleDateFormat.

Public methods

setStyle

@NonNull
public final TimeFormatComplicationText.Builder setStyle(@NonNull TimeFormatStyle style)

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

If not set, defaults to TimeFormatStyle.DEFAULT, which leaves the formatted date unchanged.

setText

@NonNull
public final TimeFormatComplicationText.Builder setText(@NonNull CharSequence text)

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

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

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

The text may contain spans, but ther watch face is not required to respect them.

The allowed spans are ForegroundColorSpan, LocaleSpan, SubscriptSpan, SuperscriptSpan, StyleSpan, StrikethroughSpan, TypefaceSpan and UnderlineSpan.

setTimeZone

@NonNull
public final TimeFormatComplicationText.Builder setTimeZone(@NonNull TimeZone timeZone)

Sets the time zone that will be used for the formatted time. If not set, the system's default time zone will be used.