Package org.apache.commons.lang3.time
Class FastDateParser.WeekDateRecorder
java.lang.Object
java.util.Calendar
java.util.GregorianCalendar
org.apache.commons.lang3.time.FastDateParser.WeekDateRecorder
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Calendar>
- Enclosing class:
- FastDateParser
A write-through recorder used while parsing a pattern that contains a week year ('Y'). Every mutation is delegated to the real target calendar
unchanged, and the raw values assigned to the three week-date fields are additionally captured, so that after all fields are parsed the week date can
be resolved from exactly what was parsed - mirroring
java.text.CalendarBuilder, which SimpleDateFormat uses for the same
purpose. (Reading the values back from the calendar instead would normalize them: Calendar.get(int) resolves the complete date, so a parsed
week 53 read back through a calendar-year interpretation can roll the year and land a full year away.)-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.Calendar
Calendar.Builder -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate intprivate static final longprivate final CalendarThe calendar every mutation is delegated to.private booleanprivate intprivate booleanprivate intFields inherited from class java.util.GregorianCalendar
AD, BCFields inherited from class java.util.Calendar
ALL_STYLES, AM, AM_PM, APRIL, areFieldsSet, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, fields, FRIDAY, HOUR, HOUR_OF_DAY, isSet, isTimeSet, JANUARY, JULY, JUNE, LONG, LONG_FORMAT, LONG_STANDALONE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NARROW_FORMAT, NARROW_STANDALONE, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SHORT, SHORT_FORMAT, SHORT_STANDALONE, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidResolves the recorded week year through the target calendar's week-date machinery.voidset(int field, int value) voidsetTimeZone(TimeZone zone) Methods inherited from class java.util.GregorianCalendar
add, clone, computeFields, computeTime, equals, from, getActualMaximum, getActualMinimum, getCalendarType, getGreatestMinimum, getGregorianChange, getLeastMaximum, getMaximum, getMinimum, getTimeZone, getWeeksInWeekYear, getWeekYear, hashCode, isLeapYear, isWeekDateSupported, roll, roll, setGregorianChange, setWeekDate, toZonedDateTimeMethods inherited from class java.util.Calendar
after, before, clear, clear, compareTo, complete, get, getAvailableCalendarTypes, getAvailableLocales, getDisplayName, getDisplayNames, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, internalGet, isLenient, isSet, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, toInstant, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
target
The calendar every mutation is delegated to. -
weekYearValue
private transient int weekYearValue -
weekYearSet
private transient boolean weekYearSet -
weekOfYearValue
private transient int weekOfYearValue -
weekOfYearSet
private transient boolean weekOfYearSet -
dayOfWeekValue
private transient int dayOfWeekValue -
dayOfWeekSet
private transient boolean dayOfWeekSet
-
-
Constructor Details
-
WeekDateRecorder
WeekDateRecorder(Calendar target)
-
-
Method Details
-
applyWeekDate
void applyWeekDate()Resolves the recorded week year through the target calendar's week-date machinery. The parsed 'Y' value was delegated intoCalendar.YEARby the number strategy;Calendar.setWeekDate(int, int, int)reinterprets it as a week year together with the parsed week of year and day of week, defaulting to week 1 and the calendar's first day-of-week when the pattern did not contain them (the same defaults asjava.text.CalendarBuilder). The fields set bysetWeekDatetake precedence over any month/day fields parsed earlier, which matchesSimpleDateFormat. -
set
public void set(int field, int value) -
setTimeZone
- Overrides:
setTimeZonein classGregorianCalendar
-