Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-5498

[classlib][text][icu][struts] DateFormatSymbols.getMonth() does not add empty string to the end of the list

    XMLWordPrintableJSON

Details

    Description

      This is a compatibility issue. Current ICU-based implementation of DateFormatSymbols#getMonths() does not add an empty string to the end of the list. This behavior is not required by the specification but RI does it. Our previous non-ICU implementation did it as well - see M4 snapshot. The same issue exists for #getWeekdays(), #getShortMonths() and #getShortWeekdays() methods. Please see the test case below.

      DateFormatSymbolsTest.java

      import java.text.DateFormatSymbols;

      public class DateFormatSymbolsTest {

      public static void main(String argv[]) {
      String[] months = new DateFormatSymbols().getMonths();

      for (String m : months)

      { System.out.println("\"" + m + "\""); }

      }

      }

      on RI (if English system locale is selected) the output is:
      "January"
      "February"
      "March"
      "April"
      "May"
      "June"
      "July"
      "August"
      "September"
      "October"
      "November"
      "December"
      ""

      on Harmony (since r612718):
      "January"
      "February"
      "March"
      "April"
      "May"
      "June"
      "July"
      "August"
      "September"
      "October"
      "November"
      "December"

      The bad news here is that some application depends on such RI behaviour. Example - Struts showcase application that comes together with Struts distribution. It directly uses "new DateFormatSymbols().getMonths();" in one of its action. And if no empty string was supplied there is no empty choice in drop-down list on the web page. So user is obliged to choose some month and can't leave the field blank. However, this is not the intended behavior.

      Our struts scenario fails since January 17 because of this issue.

      Attachments

        1. H5498-scenarioFix.patch
          0.9 kB
          Alexei Zakharov

        Activity

          People

            zakha Alexei Zakharov
            zakha Alexei Zakharov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: