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

private static final class FastDateParser.WeekDateRecorder extends GregorianCalendar
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.)
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • target

      private final Calendar 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 into Calendar.YEAR by 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 as java.text.CalendarBuilder). The fields set by setWeekDate take precedence over any month/day fields parsed earlier, which matches SimpleDateFormat.
    • set

      public void set(int field, int value)
      Overrides:
      set in class Calendar
    • setTimeZone

      public void setTimeZone(TimeZone zone)
      Overrides:
      setTimeZone in class GregorianCalendar