# DateFormat.Field

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Field

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/icu/text/DateFormat.Field "View this page in Java")  

```
open class Field : Format.Field
```

|---|---|---|------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                               ||||
| ↳ | [java.text.AttributedCharacterIterator.Attribute](https://developer.android.com/reference/kotlin/java/text/AttributedCharacterIterator.Attribute.html#) |||
|   | ↳ | [java.text.Format.Field](https://developer.android.com/reference/kotlin/java/text/Format.Field.html#)                     ||
|   |   | ↳ | [android.icu.text.DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#) |

The instances of this inner class are used as attribute keys and values in AttributedCharacterIterator that DateFormat.formatToCharacterIterator() method returns.

There is no public constructor to this class, the only instances are the constants defined here.

<br />

## Summary

|                                                                                                                                                                                                         Protected constructors                                                                                                                                                                                                          ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#Field(kotlin.String,%20kotlin.Int))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `calendarField:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Constructs a`DateFormat.Field`with the given name and the`Calendar`field which this attribute represents. |

|                                                                                                                                                                                                            Public methods                                                                                                                                                                                                             ||
|------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                   | [getCalendarField](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#getCalendarField())`()` Returns the`Calendar`field associated with this attribute.                                                                                                                              |
| openstatic[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [ofCalendarField](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#ofCalendarField(kotlin.Int))`(`calendarField:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the`Field`constant that corresponds to the` Calendar`field`calendarField`. |

|                                                                                                                           Protected methods                                                                                                                           ||
|---------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | [readResolve](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#readResolve())`()` Resolves instances being deserialized to the predefined constants. |

|                                                                                                                                                                 Properties                                                                                                                                                                 ||
|--------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [AM_PM](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#AM_PM:android.icu.text.DateFormat.Field) Constant identifying the time of day indicator(am/pm).                                     |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [AM_PM_MIDNIGHT_NOON](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#AM_PM_MIDNIGHT_NOON:android.icu.text.DateFormat.Field) **\[icu\]**Constant identifying the am/pm/midnight/noon field. |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [DAY_OF_MONTH](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#DAY_OF_MONTH:android.icu.text.DateFormat.Field) Constant identifying the day of month field.                                 |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [DAY_OF_WEEK](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#DAY_OF_WEEK:android.icu.text.DateFormat.Field) Constant identifying the day of week field.                                    |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [DAY_OF_WEEK_IN_MONTH](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#DAY_OF_WEEK_IN_MONTH:android.icu.text.DateFormat.Field) Constant identifying the day of week in month field.         |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [DAY_OF_YEAR](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#DAY_OF_YEAR:android.icu.text.DateFormat.Field) Constant identifying the day of year field.                                    |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [DOW_LOCAL](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#DOW_LOCAL:android.icu.text.DateFormat.Field) Constant identifying the local day of week field.                                  |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [ERA](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#ERA:android.icu.text.DateFormat.Field) Constant identifying the era field.                                                            |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [EXTENDED_YEAR](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#EXTENDED_YEAR:android.icu.text.DateFormat.Field) Constant identifying the extended year field.                              |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [FLEXIBLE_DAY_PERIOD](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#FLEXIBLE_DAY_PERIOD:android.icu.text.DateFormat.Field) **\[icu\]**Constant identifying the flexible day period field. |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [HOUR0](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#HOUR0:android.icu.text.DateFormat.Field) Constant identifying the hour(0-11) field.                                                 |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [HOUR1](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#HOUR1:android.icu.text.DateFormat.Field) Constant identifying the hour(1-12) field.                                                 |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [HOUR_OF_DAY0](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#HOUR_OF_DAY0:android.icu.text.DateFormat.Field) Constant identifying the hour(0-23) of day field.                            |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [HOUR_OF_DAY1](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#HOUR_OF_DAY1:android.icu.text.DateFormat.Field) Constant identifying the hour(1-24) of day field.                            |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [JULIAN_DAY](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#JULIAN_DAY:android.icu.text.DateFormat.Field) Constant identifying the Julian day field.                                       |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [MILLISECOND](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#MILLISECOND:android.icu.text.DateFormat.Field) Constant identifying the millisecond field.                                    |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [MILLISECONDS_IN_DAY](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#MILLISECONDS_IN_DAY:android.icu.text.DateFormat.Field) Constant identifying the milliseconds in day field.            |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [MINUTE](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#MINUTE:android.icu.text.DateFormat.Field) Constant identifying the minute field.                                                   |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [MONTH](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#MONTH:android.icu.text.DateFormat.Field) Constant identifying the month field.                                                      |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [QUARTER](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#QUARTER:android.icu.text.DateFormat.Field) Constant identifying the quarter field.                                                |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [SECOND](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#SECOND:android.icu.text.DateFormat.Field) Constant identifying the second field.                                                   |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [TIME_ZONE](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#TIME_ZONE:android.icu.text.DateFormat.Field) Constant identifying the time zone field.                                          |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [WEEK_OF_MONTH](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#WEEK_OF_MONTH:android.icu.text.DateFormat.Field) Constant identifying the week of month field.                              |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [WEEK_OF_YEAR](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#WEEK_OF_YEAR:android.icu.text.DateFormat.Field) Constant identifying the week of year field.                                 |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [YEAR](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#YEAR:android.icu.text.DateFormat.Field) Constant identifying the year field.                                                         |
| static[DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | [YEAR_WOY](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#YEAR_WOY:android.icu.text.DateFormat.Field) Constant identifying the year used with week of year field.                          |

## Protected constructors

### Field

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
protected Field(
    name: String!, 
    calendarField: Int)
```

Constructs a`DateFormat.Field`with the given name and the`Calendar`field which this attribute represents. Use -1 for`calendarField`if this field does not have a corresponding`Calendar`field.

|                                                        Parameters                                                        ||
|-----------------|---------------------------------------------------------------------------------------------------------|
| `name`          | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:Name of the attribute |
| `calendarField` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):`Calendar`field constant     |

## Public methods

### getCalendarField

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getCalendarField(): Int
```

Returns the`Calendar`field associated with this attribute. If there is no corresponding`Calendar`available, this will return -1.

|                                                       Return                                                       ||
|----------------------------------------------------------------------------|----------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `Calendar`constant for this attribute. |

### ofCalendarField

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open static fun ofCalendarField(calendarField: Int): DateFormat.Field!
```

Returns the`Field`constant that corresponds to the` Calendar`field`calendarField`. If there is no corresponding`Field`is available, null is returned.

|                                                      Parameters                                                      ||
|-----------------|-----------------------------------------------------------------------------------------------------|
| `calendarField` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):`Calendar`field constant |

|                                                                                             Return                                                                                              ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|
| [DateFormat.Field](https://developer.android.com/reference/kotlin/android/icu/text/DateFormat.Field#)! | `Field`associated with the`calendarField`, or null if no associated`Field`is available. |

|                                           Exceptions                                           ||
|--------------------------------------|----------------------------------------------------------|
| `java.lang.IllegalArgumentException` | if`calendarField`is not a valid`Calendar`field constant. |

## Protected methods

### readResolve

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
protected open fun readResolve(): Any!
```

Resolves instances being deserialized to the predefined constants.

|                                                   Return                                                   ||
|-----------------------------------------------------------------------------|-------------------------------|
| [Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)! | the resolved`Attribute`object |

|                                Exceptions                                ||
|----------------------------------|----------------------------------------|
| `java.io.InvalidObjectException` | if the constant could not be resolved. |

## Properties

### AM_PM

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val AM_PM: DateFormat.Field!
```

Constant identifying the time of day indicator(am/pm).  

### AM_PM_MIDNIGHT_NOON

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val AM_PM_MIDNIGHT_NOON: DateFormat.Field!
```

**\[icu\]**Constant identifying the am/pm/midnight/noon field.  

### DAY_OF_MONTH

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val DAY_OF_MONTH: DateFormat.Field!
```

Constant identifying the day of month field.  

### DAY_OF_WEEK

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val DAY_OF_WEEK: DateFormat.Field!
```

Constant identifying the day of week field.  

### DAY_OF_WEEK_IN_MONTH

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val DAY_OF_WEEK_IN_MONTH: DateFormat.Field!
```

Constant identifying the day of week in month field.  

### DAY_OF_YEAR

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val DAY_OF_YEAR: DateFormat.Field!
```

Constant identifying the day of year field.  

### DOW_LOCAL

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val DOW_LOCAL: DateFormat.Field!
```

Constant identifying the local day of week field.  

### ERA

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val ERA: DateFormat.Field!
```

Constant identifying the era field.  

### EXTENDED_YEAR

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val EXTENDED_YEAR: DateFormat.Field!
```

Constant identifying the extended year field.  

### FLEXIBLE_DAY_PERIOD

Added in[API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FLEXIBLE_DAY_PERIOD: DateFormat.Field!
```

**\[icu\]**Constant identifying the flexible day period field.  

### HOUR0

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val HOUR0: DateFormat.Field!
```

Constant identifying the hour(0-11) field.  

### HOUR1

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val HOUR1: DateFormat.Field!
```

Constant identifying the hour(1-12) field.  

### HOUR_OF_DAY0

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val HOUR_OF_DAY0: DateFormat.Field!
```

Constant identifying the hour(0-23) of day field.  

### HOUR_OF_DAY1

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val HOUR_OF_DAY1: DateFormat.Field!
```

Constant identifying the hour(1-24) of day field.  

### JULIAN_DAY

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val JULIAN_DAY: DateFormat.Field!
```

Constant identifying the Julian day field.  

### MILLISECOND

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val MILLISECOND: DateFormat.Field!
```

Constant identifying the millisecond field.  

### MILLISECONDS_IN_DAY

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val MILLISECONDS_IN_DAY: DateFormat.Field!
```

Constant identifying the milliseconds in day field.  

### MINUTE

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val MINUTE: DateFormat.Field!
```

Constant identifying the minute field.  

### MONTH

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val MONTH: DateFormat.Field!
```

Constant identifying the month field.  

### QUARTER

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val QUARTER: DateFormat.Field!
```

Constant identifying the quarter field.  

### SECOND

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val SECOND: DateFormat.Field!
```

Constant identifying the second field.  

### TIME_ZONE

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val TIME_ZONE: DateFormat.Field!
```

Constant identifying the time zone field.  

### WEEK_OF_MONTH

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val WEEK_OF_MONTH: DateFormat.Field!
```

Constant identifying the week of month field.  

### WEEK_OF_YEAR

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val WEEK_OF_YEAR: DateFormat.Field!
```

Constant identifying the week of year field.  

### YEAR

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val YEAR: DateFormat.Field!
```

Constant identifying the year field.  

### YEAR_WOY

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val YEAR_WOY: DateFormat.Field!
```

Constant identifying the year used with week of year field.