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 |
|---|
public final class DateTimeFormatterSkeletonOptions.BuilderThe |
public final class DateTimeFormatterSkeletonOptions.DayDay of month (numeric). |
public final class DateTimeFormatterSkeletonOptions.EraEra name. |
public final class DateTimeFormatterSkeletonOptions.FractionalSecondFractional Second (numeric). |
public final class DateTimeFormatterSkeletonOptions.HourHour (numeric). |
public final class DateTimeFormatterSkeletonOptions.MinuteMinute (numeric). |
public final class DateTimeFormatterSkeletonOptions.MonthMonth number/name. |
public final class DateTimeFormatterSkeletonOptions.PeriodThe period of the day, if the hour is not 23h or 24h style. |
public final class DateTimeFormatterSkeletonOptions.SecondSecond (numeric). |
public final class DateTimeFormatterSkeletonOptions.TimezoneThe localized representation of the time zone name. |
public final class DateTimeFormatterSkeletonOptions.WeekDayDay of week name. |
public final class DateTimeFormatterSkeletonOptions.YearCalendar year (numeric). |
Public methods
fromString
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. |
| Returns | |
|---|---|
@NonNull DateTimeFormatterSkeletonOptions |
the formatting options to use with |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the |
kotlin.RuntimeException |
library error (unknown skeleton field encountered). |
getDay
public final @NonNull DateTimeFormatterSkeletonOptions.Day getDay()
Returns the day option.
getEra
public final @NonNull DateTimeFormatterSkeletonOptions.Era getEra()
Returns the era option.
getFractionalSecond
public final @NonNull DateTimeFormatterSkeletonOptions.FractionalSecond getFractionalSecond()
Returns the fractional second option.
getHour
public final @NonNull DateTimeFormatterSkeletonOptions.Hour getHour()
Returns the hour option.
getMinute
public final @NonNull DateTimeFormatterSkeletonOptions.Minute getMinute()
Returns the minutes option.
getMonth
public final @NonNull DateTimeFormatterSkeletonOptions.Month getMonth()
Returns the month option.
getPeriod
public final @NonNull DateTimeFormatterSkeletonOptions.Period getPeriod()
Returns the day period option.
getSecond
public final @NonNull DateTimeFormatterSkeletonOptions.Second getSecond()
Returns the seconds option.
getTimezone
public final @NonNull DateTimeFormatterSkeletonOptions.Timezone getTimezone()
Returns the timezone option.
getWeekDay
public final @NonNull DateTimeFormatterSkeletonOptions.WeekDay getWeekDay()
Returns the day of week option.
getYear
public final @NonNull DateTimeFormatterSkeletonOptions.Year getYear()
Returns the year option.