DateTimeFormatterSkeletonOptions


public final 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 methods

static final @NonNull DateTimeFormatterSkeletonOptions

Creates the a DateTimeFormatterSkeletonOptions object from a string.

final @NonNull DateTimeFormatterSkeletonOptions.Day

Returns the day option.

final @NonNull DateTimeFormatterSkeletonOptions.Era

Returns the era option.

final @NonNull DateTimeFormatterSkeletonOptions.FractionalSecond

Returns the fractional second option.

final @NonNull DateTimeFormatterSkeletonOptions.Hour

Returns the hour option.

final @NonNull DateTimeFormatterSkeletonOptions.Minute

Returns the minutes option.

final @NonNull DateTimeFormatterSkeletonOptions.Month

Returns the month option.

final @NonNull DateTimeFormatterSkeletonOptions.Period

Returns the day period option.

final @NonNull DateTimeFormatterSkeletonOptions.Second

Returns the seconds option.

final @NonNull DateTimeFormatterSkeletonOptions.Timezone

Returns the timezone option.

final @NonNull DateTimeFormatterSkeletonOptions.WeekDay

Returns the day of week option.

final @NonNull DateTimeFormatterSkeletonOptions.Year

Returns the year option.

@NonNull String

Public methods

fromString

Added in 1.0.0-alpha01
public static final @NonNull DateTimeFormatterSkeletonOptions fromString(@NonNull String value)

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
@NonNull String value

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

Throws
kotlin.IllegalArgumentException

if the value contains an unknown skeleton field.

kotlin.RuntimeException

library error (unknown skeleton field encountered).

getDay

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.Day getDay()

Returns the day option.

getEra

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.Era getEra()

Returns the era option.

getFractionalSecond

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.FractionalSecond getFractionalSecond()

Returns the fractional second option.

getHour

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.Hour getHour()

Returns the hour option.

getMinute

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.Minute getMinute()

Returns the minutes option.

getMonth

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.Month getMonth()

Returns the month option.

getPeriod

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.Period getPeriod()

Returns the day period option.

getSecond

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.Second getSecond()

Returns the seconds option.

getTimezone

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.Timezone getTimezone()

Returns the timezone option.

getWeekDay

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.WeekDay getWeekDay()

Returns the day of week option.

getYear

Added in 1.0.0-alpha01
public final @NonNull DateTimeFormatterSkeletonOptions.Year getYear()

Returns the year option.

toString

public @NonNull String toString()