# DateTimeFormatterSkeletonOptions

Artifact: [androidx.core:core-i18n](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/i18n/DateTimeFormatterSkeletonOptions.kt+class:androidx.core.i18n.DateTimeFormatterSkeletonOptions) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

*** ** * ** ***


```
public final class DateTimeFormatterSkeletonOptions
```

<br />

*** ** * ** ***

This class helps one create skeleton options for `https://developer.android.com/reference/androidx/core/i18n/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](https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table), but uses a builder to make things safer an more discoverable.

You can still build these options from a string by using the `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#fromString(kotlin.String)` method.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Builder` The `Builder` class used to construct a `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions` in a way that is safe and discoverable. |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Day` Day of month (numeric). |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Era` Era name. |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.FractionalSecond` Fractional Second (numeric). |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Hour` Hour (numeric). |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Minute` Minute (numeric). |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Month` Month number/name. |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Period` The period of the day, if the hour is not 23h or 24h style. |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Second` Second (numeric). |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Timezone` The localized representation of the time zone name. |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.WeekDay` Day of week name. |
| `public final class https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Year` Calendar year (numeric). |

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#fromString(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value)` Creates the a `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions` object from a string. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Day` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getDay()()` Returns the day option. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Era` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getEra()()` Returns the era option. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.FractionalSecond` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getFractionalSecond()()` Returns the fractional second option. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Hour` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getHour()()` Returns the hour option. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Minute` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getMinute()()` Returns the minutes option. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Month` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getMonth()()` Returns the month option. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Period` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getPeriod()()` Returns the day period option. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Second` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getSecond()()` Returns the seconds option. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Timezone` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getTimezone()()` Returns the timezone option. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.WeekDay` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getWeekDay()()` Returns the day of week option. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Year` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#getYear()()` Returns the year option. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions#toString()()` |

## Public methods

### fromString

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public static final @NonNull DateTimeFormatterSkeletonOptions fromString(@NonNull String value)
```

Creates the a `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions` object from a string.

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value` | the skeleton that specifies the fields to be formatted and their length. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions` | the formatting options to use with `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatter`. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the `https://developer.android.com/reference/androidx/core/i18n/DateTimeFormatterSkeletonOptions.Companion#fromString(kotlin.String)` contains an unknown skeleton field. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-runtime-exception/index.html` | library error (unknown skeleton field encountered). |

### getDay

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.Day getDay()
```

Returns the day option.

### getEra

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.Era getEra()
```

Returns the era option.

### getFractionalSecond

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.FractionalSecond getFractionalSecond()
```

Returns the fractional second option.

### getHour

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.Hour getHour()
```

Returns the hour option.

### getMinute

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.Minute getMinute()
```

Returns the minutes option.

### getMonth

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.Month getMonth()
```

Returns the month option.

### getPeriod

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.Period getPeriod()
```

Returns the day period option.

### getSecond

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.Second getSecond()
```

Returns the seconds option.

### getTimezone

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.Timezone getTimezone()
```

Returns the timezone option.

### getWeekDay

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.WeekDay getWeekDay()
```

Returns the day of week option.

### getYear

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/core#1.0.0)

```
public final @NonNull DateTimeFormatterSkeletonOptions.Year getYear()
```

Returns the year option.

### toString

```
public @NonNull String toString()
```