Package java.text
Class DateFormat.Field
java.lang.Object
java.text.AttributedCharacterIterator.Attribute
java.text.Format.Field
java.text.DateFormat.Field
- All Implemented Interfaces:
Serializable
- Enclosing class:
- DateFormat
public static class DateFormat.Field extends Format.Field
The instances of this inner class are used as attribute keys and values
in
AttributedCharacterIterator that the
SimpleDateFormat.formatToCharacterIterator(Object) method returns.
There is no public constructor in this class, the only instances are the constants defined here.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static DateFormat.FieldAM_PMMarks the time indicator part of a date.static DateFormat.FieldDAY_OF_MONTHMarks the day of the month part of a date.static DateFormat.FieldDAY_OF_WEEKMarks the day of the week part of a date.static DateFormat.FieldDAY_OF_WEEK_IN_MONTHMarks the day of the week in the month part of a date.static DateFormat.FieldDAY_OF_YEARMarks the day of the year part of a date.static DateFormat.FieldERAMarks the era part of a date.static DateFormat.FieldHOUR_OF_DAY0Marks the hour of the day part of a date (0-11).static DateFormat.FieldHOUR_OF_DAY1Marks the hour of the day part of a date (1-12).static DateFormat.FieldHOUR0Marks the hour part of a date (0-11).static DateFormat.FieldHOUR1Marks the hour part of a date (1-12).static DateFormat.FieldMILLISECONDMarks the millisecond part of a time.static DateFormat.FieldMINUTEMarks the minute part of a time.static DateFormat.FieldMONTHMarks the month part of a date.static DateFormat.FieldSECONDMarks the second part of a time.static DateFormat.FieldTIME_ZONEMarks the time zone part of a date.static DateFormat.FieldWEEK_OF_MONTHMarks the week of the month part of a date.static DateFormat.FieldWEEK_OF_YEARMarks the week of the year part of a date.static DateFormat.FieldYEARMarks the year part of a date.Fields inherited from class java.text.AttributedCharacterIterator.Attribute
INPUT_METHOD_SEGMENT, LANGUAGE, READING -
Constructor Summary
-
Method Summary
Modifier and Type Method Description intgetCalendarField()Returns the Calendar field that this field represents.static DateFormat.FieldofCalendarField(int calendarField)Returns theDateFormat.Fieldinstance for the given calendar field.Methods inherited from class java.text.AttributedCharacterIterator.Attribute
equals, getName, hashCode, readResolve, toString
-
Field Details
-
ERA
Marks the era part of a date. -
YEAR
Marks the year part of a date. -
MONTH
Marks the month part of a date. -
HOUR_OF_DAY0
Marks the hour of the day part of a date (0-11). -
HOUR_OF_DAY1
Marks the hour of the day part of a date (1-12). -
MINUTE
Marks the minute part of a time. -
SECOND
Marks the second part of a time. -
MILLISECOND
Marks the millisecond part of a time. -
DAY_OF_WEEK
Marks the day of the week part of a date. -
DAY_OF_MONTH
Marks the day of the month part of a date. -
DAY_OF_YEAR
Marks the day of the year part of a date. -
DAY_OF_WEEK_IN_MONTH
Marks the day of the week in the month part of a date. -
WEEK_OF_YEAR
Marks the week of the year part of a date. -
WEEK_OF_MONTH
Marks the week of the month part of a date. -
AM_PM
Marks the time indicator part of a date. -
HOUR0
Marks the hour part of a date (0-11). -
HOUR1
Marks the hour part of a date (1-12). -
TIME_ZONE
Marks the time zone part of a date.
-
-
Constructor Details
-
Field
Constructs a new instance ofDateFormat.Fieldwith the given fieldName and calendar field.- Parameters:
fieldName- the field name.calendarField- the calendar field type of the field.
-
-
Method Details
-
getCalendarField
public int getCalendarField()Returns the Calendar field that this field represents.- Returns:
- the calendar field.
-
ofCalendarField
Returns theDateFormat.Fieldinstance for the given calendar field.- Parameters:
calendarField- a calendar field constant.- Returns:
- the
DateFormat.Fieldcorresponding tocalendarField. - Throws:
IllegalArgumentException- ifcalendarFieldis negative or greater than the field count ofCalendar.
-