Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4209721

RFE: Calendar is too difficult to subclass

XMLWordPrintable



      Name: bb33257 Date: 02/08/99


      Currently, java.util.Calendar is very difficult
      to subclass. There ends up being a huge amount of
      boilerplate code that must be duplicated in each
      subclass. I found this out while implementing four
      new calendar classes, which are available at
      http://www.alphaWorks.ibm.com/formula/calendars.

      The worst examples are the "add" and "roll" methods.
      The vast majority of the code in these methods is
      common to all subclasses. Only subclasses that have
      fields with weird behavior, e.g. Hebrew leap months,
      need to do anything special in these methods. Other
      calendars (e.g. Islamic) would work fine with a
      generic implementation.

      We need to add generic implementations of "add" and
      "roll", and perhaps a few other methods, to Calendar
      so that subclasses can call them rather than creating
      their own, identical, implementations of the methods.
      The generic versions could be provided either as
      default implementations of the current "add" and "roll"
      methods (making them non-abstract), or as separate
      "handleAdd" and "handleRoll" methods that subclasses
      could call if needed.
      (Review ID: 53908)

      ======================================================================

            okutsu Masayoshi Okutsu
            bcbeck Brian Beck (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: