# DateFormat.Field

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Fields](https://developer.android.com/reference/java/text/DateFormat.Field#lfields)\|[Inherited Fields](https://developer.android.com/reference/java/text/DateFormat.Field#inhfields)\|[Protected Ctors](https://developer.android.com/reference/java/text/DateFormat.Field#proctors)\|[Methods](https://developer.android.com/reference/java/text/DateFormat.Field#pubmethods)\|[Protected Methods](https://developer.android.com/reference/java/text/DateFormat.Field#promethods)\|[Inherited Methods](https://developer.android.com/reference/java/text/DateFormat.Field#inhmethods)  

# DateFormat.Field

`
public
static


class
DateFormat.Field
`  
`


``


``

extends `[Format.Field](https://developer.android.com/reference/java/text/Format.Field)`


``


`

|---|---|---|----------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||||
| ↳ | [java.text.AttributedCharacterIterator.Attribute](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute) |||
|   | ↳ | [java.text.Format.Field](https://developer.android.com/reference/java/text/Format.Field) ||
|   |   | ↳ | java.text.DateFormat.Field |

<br />

*** ** * ** ***

Defines constants that are used as attribute keys in the`AttributedCharacterIterator`returned from`DateFormat.formatToCharacterIterator`and as field identifiers in`FieldPosition`.

The class also provides two methods to map between its constants and the corresponding Calendar constants.  
**See also:**

- [Calendar](https://developer.android.com/reference/java/util/Calendar)

## Summary

|                                                                                                                                           ### Fields                                                                                                                                           ||
|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [AM_PM](https://developer.android.com/reference/java/text/DateFormat.Field#AM_PM) Constant identifying the time of day indicator (e.g. "a.m." or "p.m.") field.                 |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [DAY_OF_MONTH](https://developer.android.com/reference/java/text/DateFormat.Field#DAY_OF_MONTH) Constant identifying the day of month field.                                    |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [DAY_OF_WEEK](https://developer.android.com/reference/java/text/DateFormat.Field#DAY_OF_WEEK) Constant identifying the day of week field.                                       |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [DAY_OF_WEEK_IN_MONTH](https://developer.android.com/reference/java/text/DateFormat.Field#DAY_OF_WEEK_IN_MONTH) Constant identifying the day of week field.                     |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [DAY_OF_YEAR](https://developer.android.com/reference/java/text/DateFormat.Field#DAY_OF_YEAR) Constant identifying the day of year field.                                       |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [ERA](https://developer.android.com/reference/java/text/DateFormat.Field#ERA) Constant identifying the era field.                                                               |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [HOUR0](https://developer.android.com/reference/java/text/DateFormat.Field#HOUR0) Constant identifying the hour field, where the legal values are 0 to 11.                      |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [HOUR1](https://developer.android.com/reference/java/text/DateFormat.Field#HOUR1) Constant identifying the hour field, where the legal values are 1 to 12.                      |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [HOUR_OF_DAY0](https://developer.android.com/reference/java/text/DateFormat.Field#HOUR_OF_DAY0) Constant identifying the hour of day field, where the legal values are 0 to 23. |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [HOUR_OF_DAY1](https://developer.android.com/reference/java/text/DateFormat.Field#HOUR_OF_DAY1) Constant identifying the hour of day field, where the legal values are 1 to 24. |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [MILLISECOND](https://developer.android.com/reference/java/text/DateFormat.Field#MILLISECOND) Constant identifying the millisecond field.                                       |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [MINUTE](https://developer.android.com/reference/java/text/DateFormat.Field#MINUTE) Constant identifying the minute field.                                                      |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [MONTH](https://developer.android.com/reference/java/text/DateFormat.Field#MONTH) Constant identifying the month field.                                                         |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [SECOND](https://developer.android.com/reference/java/text/DateFormat.Field#SECOND) Constant identifying the second field.                                                      |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [TIME_ZONE](https://developer.android.com/reference/java/text/DateFormat.Field#TIME_ZONE) Constant identifying the time zone field.                                             |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [WEEK_OF_MONTH](https://developer.android.com/reference/java/text/DateFormat.Field#WEEK_OF_MONTH) Constant identifying the week of month field.                                 |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [WEEK_OF_YEAR](https://developer.android.com/reference/java/text/DateFormat.Field#WEEK_OF_YEAR) Constant identifying the week of year field.                                    |
| ` public static final `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | [YEAR](https://developer.android.com/reference/java/text/DateFormat.Field#YEAR) Constant identifying the year field.                                                            |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ### Inherited fields                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From class[java.text.AttributedCharacterIterator.Attribute](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute) |---------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` public static final `[AttributedCharacterIterator.Attribute](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute) | [INPUT_METHOD_SEGMENT](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute#INPUT_METHOD_SEGMENT) Attribute key for input method segments. | | ` public static final `[AttributedCharacterIterator.Attribute](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute) | [LANGUAGE](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute#LANGUAGE) Attribute key for the language of some text.                     | | ` public static final `[AttributedCharacterIterator.Attribute](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute) | [READING](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute#READING) Attribute key for the reading of some text.                        | |

|                                                                                                     ### Protected constructors                                                                                                      ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Field](https://developer.android.com/reference/java/text/DateFormat.Field#Field(java.lang.String,%20int))`(`[String](https://developer.android.com/reference/java/lang/String)` name, int calendarField) ` Creates a`Field`. |

|                                                                                                                                                     ### Public methods                                                                                                                                                     ||
|--------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` int`                                                                                           | ` `[getCalendarField](https://developer.android.com/reference/java/text/DateFormat.Field#getCalendarField())`() ` Returns the`Calendar`field associated with this attribute.                                             |
| ` static `[DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | ` `[ofCalendarField](https://developer.android.com/reference/java/text/DateFormat.Field#ofCalendarField(int))`(int calendarField) ` Returns the`Field`constant that corresponds to the`Calendar`constant`calendarField`. |

|                                                                                                               ### Protected methods                                                                                                               ||
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Object](https://developer.android.com/reference/java/lang/Object) | ` `[readResolve](https://developer.android.com/reference/java/text/DateFormat.Field#readResolve())`() ` Resolves instances being deserialized to the predefined constants. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.text.AttributedCharacterIterator.Attribute](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute)` ` |-----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` final boolean`                                                      | ` `[equals](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Compares two objects for equality. | | ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[getName](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute#getName())`() ` Returns the name of the attribute.                                                                                       | | ` final int`                                                          | ` `[hashCode](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute#hashCode())`() ` Returns a hash code value for the object.                                                                              | | ` `[Object](https://developer.android.com/reference/java/lang/Object) | ` `[readResolve](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute#readResolve())`() ` Resolves instances being deserialized to the predefined constants.                                               | | ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[toString](https://developer.android.com/reference/java/text/AttributedCharacterIterator.Attribute#toString())`() ` Returns a string representation of the object.                                                                         | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Fields

### AM_PM

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

```
public static final DateFormat.Field AM_PM
```

Constant identifying the time of day indicator (e.g. "a.m." or "p.m.") field.

<br />

### DAY_OF_MONTH

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

```
public static final DateFormat.Field DAY_OF_MONTH
```

Constant identifying the day of month field.

<br />

### DAY_OF_WEEK

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

```
public static final DateFormat.Field DAY_OF_WEEK
```

Constant identifying the day of week field.

<br />

### DAY_OF_WEEK_IN_MONTH

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

```
public static final DateFormat.Field DAY_OF_WEEK_IN_MONTH
```

Constant identifying the day of week field.

<br />

### DAY_OF_YEAR

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

```
public static final DateFormat.Field DAY_OF_YEAR
```

Constant identifying the day of year field.

<br />

### ERA

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

```
public static final DateFormat.Field ERA
```

Constant identifying the era field.

<br />

### HOUR0

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

```
public static final DateFormat.Field HOUR0
```

Constant identifying the hour field, where the legal values are 0 to 11.

<br />

### HOUR1

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

```
public static final DateFormat.Field HOUR1
```

Constant identifying the hour field, where the legal values are 1 to 12.

<br />

### HOUR_OF_DAY0

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

```
public static final DateFormat.Field HOUR_OF_DAY0
```

Constant identifying the hour of day field, where the legal values are 0 to 23.

<br />

### HOUR_OF_DAY1

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

```
public static final DateFormat.Field HOUR_OF_DAY1
```

Constant identifying the hour of day field, where the legal values are 1 to 24.

<br />

### MILLISECOND

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

```
public static final DateFormat.Field MILLISECOND
```

Constant identifying the millisecond field.

<br />

### MINUTE

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

```
public static final DateFormat.Field MINUTE
```

Constant identifying the minute field.

<br />

### MONTH

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

```
public static final DateFormat.Field MONTH
```

Constant identifying the month field.

<br />

### SECOND

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

```
public static final DateFormat.Field SECOND
```

Constant identifying the second field.

<br />

### TIME_ZONE

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

```
public static final DateFormat.Field TIME_ZONE
```

Constant identifying the time zone field.

<br />

### WEEK_OF_MONTH

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

```
public static final DateFormat.Field WEEK_OF_MONTH
```

Constant identifying the week of month field.

<br />

### WEEK_OF_YEAR

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

```
public static final DateFormat.Field WEEK_OF_YEAR
```

Constant identifying the week of year field.

<br />

### YEAR

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

```
public static final DateFormat.Field YEAR
```

Constant identifying the year field.

<br />

## Protected constructors

### Field

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

```
protected Field (String name, 
                int calendarField)
```

Creates a`Field`.

<br />

|                                                                                                                 Parameters                                                                                                                  ||
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`          | `String`: the name of the`Field` <br />                                                                                                                                                                                    |
| `calendarField` | `int`: the`Calendar`constant this`Field`corresponds to; any value, even one outside the range of legal`Calendar`values may be used, but`-1`should be used for values that don't correspond to legal`Calendar`values <br /> |

## Public methods

### getCalendarField

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

```
public int getCalendarField ()
```

Returns the`Calendar`field associated with this attribute. For example, if this represents the hours field of a`Calendar`, this would return`Calendar.HOUR`. If there is no corresponding`Calendar`constant, this will return -1.

<br />

|                    Returns                     ||
|-------|-----------------------------------------|
| `int` | Calendar constant for this field <br /> |

**See also:**

- [Calendar](https://developer.android.com/reference/java/util/Calendar)  

### ofCalendarField

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

```
public static DateFormat.Field ofCalendarField (int calendarField)
```

Returns the`Field`constant that corresponds to the`Calendar`constant`calendarField`. If there is no direct mapping between the`Calendar`constant and a`Field`, null is returned.

<br />

|                       Parameters                       ||
|-----------------|---------------------------------------|
| `calendarField` | `int`: Calendar field constant <br /> |

|                                                                  Returns                                                                  ||
|----------------------------------------------------------------------------------------|---------------------------------------------------|
| [DateFormat.Field](https://developer.android.com/reference/java/text/DateFormat.Field) | Field instance representing calendarField. <br /> |

|                                                                                 Throws                                                                                  ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if`calendarField`is not the value of a`Calendar`field constant. |

**See also:**

- [Calendar](https://developer.android.com/reference/java/util/Calendar)

## Protected methods

### readResolve

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

```
protected Object readResolve ()
```

Resolves instances being deserialized to the predefined constants.

<br />

|                                                    Returns                                                    ||
|--------------------------------------------------------------------|-------------------------------------------|
| [Object](https://developer.android.com/reference/java/lang/Object) | resolved DateFormat.Field constant <br /> |

|                                                                  Throws                                                                  ||
|--------------------------------------------------------------------------------------------------|----------------------------------------|
| [InvalidObjectException](https://developer.android.com/reference/java/io/InvalidObjectException) | if the constant could not be resolved. |