DateTimeFormatterSkeletonOptions


class DateTimeFormatterSkeletonOptions


This class helps one create skeleton options for DateTimeFormatter in a safer and more discoverable manner than using raw strings.

Skeletons are a flexible way to specify (in a locale independent manner) how to format of a date / time.

It can be used for example to specify that a formatted date should contain a day-of-month, an abbreviated month name, and a year.

It does not specify the order of the fields, or the separators, those will depend on the locale.

The result will be locale dependent: "Aug 17, 2022" for English U.S., "17 Aug 2022" for English - Great Britain, "2022年8月17日" for Japanese.

Skeletons are based on the Unicode Technical Standard #35, but uses a builder to make things safer an more discoverable.

You can still build these options from a string by using the DateTimeFormatterSkeletonOptions.fromString method.

Summary

Nested types

The Builder class used to construct a DateTimeFormatterSkeletonOptions in a way that is safe and discoverable.

Day of month (numeric).

Era name.

Fractional Second (numeric).

Hour (numeric).

Minute (numeric).

Month number/name.

The period of the day, if the hour is not 23h or 24h style.

Second (numeric).

The localized representation of the time zone name.

Day of week name.

Calendar year (numeric).

Public companion functions

DateTimeFormatterSkeletonOptions

Creates the a DateTimeFormatterSkeletonOptions object from a string.

Public functions

DateTimeFormatterSkeletonOptions.Day

Returns the day option.

DateTimeFormatterSkeletonOptions.Era

Returns the era option.

DateTimeFormatterSkeletonOptions.FractionalSecond

Returns the fractional second option.

DateTimeFormatterSkeletonOptions.Hour

Returns the hour option.

DateTimeFormatterSkeletonOptions.Minute

Returns the minutes option.

DateTimeFormatterSkeletonOptions.Month

Returns the month option.

DateTimeFormatterSkeletonOptions.Period

Returns the day period option.

DateTimeFormatterSkeletonOptions.Second

Returns the seconds option.

DateTimeFormatterSkeletonOptions.Timezone

Returns the timezone option.

DateTimeFormatterSkeletonOptions.WeekDay

Returns the day of week option.

DateTimeFormatterSkeletonOptions.Year

Returns the year option.

open String

Public companion functions

fromString

Added in 1.0.0-alpha01
fun fromString(value: String): DateTimeFormatterSkeletonOptions

Creates the a DateTimeFormatterSkeletonOptions object from a string.

Although less discoverable than using the Builder, it is useful for serialization, and to implement the MessageFormat functionality.

Parameters
value: String

the skeleton that specifies the fields to be formatted and their length.

Returns
DateTimeFormatterSkeletonOptions

the formatting options to use with androidx.core.i18n.DateTimeFormatter.

Throws
kotlin.IllegalArgumentException

if the value contains an unknown skeleton field.

kotlin.RuntimeException

library error (unknown skeleton field encountered).

Public functions

getDay

Added in 1.0.0-alpha01
fun getDay(): DateTimeFormatterSkeletonOptions.Day

Returns the day option.

getEra

Added in 1.0.0-alpha01
fun getEra(): DateTimeFormatterSkeletonOptions.Era

Returns the era option.

getFractionalSecond

Added in 1.0.0-alpha01
fun getFractionalSecond(): DateTimeFormatterSkeletonOptions.FractionalSecond

Returns the fractional second option.

getHour

Added in 1.0.0-alpha01
fun getHour(): DateTimeFormatterSkeletonOptions.Hour

Returns the hour option.

getMinute

Added in 1.0.0-alpha01
fun getMinute(): DateTimeFormatterSkeletonOptions.Minute

Returns the minutes option.

getMonth

Added in 1.0.0-alpha01
fun getMonth(): DateTimeFormatterSkeletonOptions.Month

Returns the month option.

getPeriod

Added in 1.0.0-alpha01
fun getPeriod(): DateTimeFormatterSkeletonOptions.Period

Returns the day period option.

getSecond

Added in 1.0.0-alpha01
fun getSecond(): DateTimeFormatterSkeletonOptions.Second

Returns the seconds option.

getTimezone

Added in 1.0.0-alpha01
fun getTimezone(): DateTimeFormatterSkeletonOptions.Timezone

Returns the timezone option.

getWeekDay

Added in 1.0.0-alpha01
fun getWeekDay(): DateTimeFormatterSkeletonOptions.WeekDay

Returns the day of week option.

getYear

Added in 1.0.0-alpha01
fun getYear(): DateTimeFormatterSkeletonOptions.Year

Returns the year option.

toString

open fun toString(): String