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 |
|
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 |
fromString(value: String)Creates the a |
Public functions |
|
|---|---|
DateTimeFormatterSkeletonOptions.Day |
getDay()Returns the day option. |
DateTimeFormatterSkeletonOptions.Era |
getEra()Returns the era option. |
DateTimeFormatterSkeletonOptions.FractionalSecond |
Returns the fractional second option. |
DateTimeFormatterSkeletonOptions.Hour |
getHour()Returns the hour option. |
DateTimeFormatterSkeletonOptions.Minute |
Returns the minutes option. |
DateTimeFormatterSkeletonOptions.Month |
getMonth()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 |
getYear()Returns the year option. |
open String |
toString() |
Public companion functions
fromString
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 |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
kotlin.RuntimeException |
library error (unknown skeleton field encountered). |
Public functions
getFractionalSecond
fun getFractionalSecond(): DateTimeFormatterSkeletonOptions.FractionalSecond
Returns the fractional second option.
getHour
fun getHour(): DateTimeFormatterSkeletonOptions.Hour
Returns the hour option.
getMinute
fun getMinute(): DateTimeFormatterSkeletonOptions.Minute
Returns the minutes option.
getMonth
fun getMonth(): DateTimeFormatterSkeletonOptions.Month
Returns the month option.
getPeriod
fun getPeriod(): DateTimeFormatterSkeletonOptions.Period
Returns the day period option.
getSecond
fun getSecond(): DateTimeFormatterSkeletonOptions.Second
Returns the seconds option.
getTimezone
fun getTimezone(): DateTimeFormatterSkeletonOptions.Timezone
Returns the timezone option.
getWeekDay
fun getWeekDay(): DateTimeFormatterSkeletonOptions.WeekDay
Returns the day of week option.
getYear
fun getYear(): DateTimeFormatterSkeletonOptions.Year
Returns the year option.