Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-884

Simplify FastDateFormat; eliminate boxing

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1
    • 3.2
    • lang.time.*
    • None

    Description

      FastDateFormat calls the method FormatCache.getDateTimeInstance(Integer, Integer, ...) several times. There are some issues with this:

      • the two Integer parameters could be mixed up
      • the int parameters have to be boxed into Integers
      • the FastDateFormat class has to 'know' that FormatCache uses null for no date/no time.

      The FormatCache class could be extended to add getDate, getTime and getDateTime methods with int parameters, and the calling sequences would them be a lot more obvious. Instead of:

      public static FastDateFormat getDateInstance(final int style) {
          return cache.getDateTimeInstance(style, null, null, null);
      }
      

      one could write:

      public static FastDateFormat getDateInstance(final int style) {
          return cache.getDateInstance(style, null, null);
      }
      

      The FormatCache class would then be responsible for boxing the date and time int values as necessary.

      As well as simplifying the FastDateFormat code, it would also allow the FormatCache code to be reworked. Only it would know that null is currently used for a missing date or time; and it could be changed to use a different representation if that was better.

      Attachments

        1. LANG-884.patch
          6 kB
          Sebb

        Activity

          People

            Unassigned Unassigned
            sebb Sebb
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: