Java™ Platform
Standard Ed. 8
compact1, compact2, compact3
java.text
Class DateFormat.Field
-
-
Constructor Summary
Constructors
| Modifier |
Constructor |
Description |
protected |
Field(String name,
int calendarField) |
Creates a Field.
|
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
| Modifier and Type |
Method |
Description |
int |
getCalendarField() |
Returns the Calendar field associated with this
attribute.
|
static DateFormat.Field |
ofCalendarField(int calendarField) |
Returns the Field constant that corresponds to
the Calendar constant calendarField.
|
protected Object |
readResolve() |
Resolves instances being deserialized to the predefined constants.
|
-
-
Field Detail
-
HOUR_OF_DAY1
public static final DateFormat.Field HOUR_OF_DAY1
Constant identifying the hour of day field, where the legal values
are 1 to 24.
-
HOUR_OF_DAY0
public static final DateFormat.Field HOUR_OF_DAY0
Constant identifying the hour of day field, where the legal values
are 0 to 23.
-
HOUR1
public static final DateFormat.Field HOUR1
Constant identifying the hour field, where the legal values are
1 to 12.
-
HOUR0
public static final DateFormat.Field HOUR0
Constant identifying the hour field, where the legal values are
0 to 11.
-
Method Detail
-
ofCalendarField
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.
- Parameters:
calendarField - Calendar field constant
- Returns:
- Field instance representing calendarField.
- Throws:
IllegalArgumentException - if calendarField is
not the value of a Calendar field constant.
- See Also:
Calendar
-
getCalendarField
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.
- Returns:
- Calendar constant for this field
- See Also:
Calendar
Java™ Platform
Standard Ed. 8
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.