Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-13914

Date Format does not handle January correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • Adobe Flex SDK Previous
    • None
    • Formatters
    • None
    • Affected OS(s): All OS Platforms
      Language Found: English

    Description

      The DateFormat class handles January incorrectly. According to the docs, dates use a zero-based numbering system, but the dateFormat classes parses a month of "1" into January anyway. It parses the other dates correctly, which is to say that a month of 2 is March, 3 is April, etc.

      For example, if you run the following block of code:

      var formatter:DateFormat = new DateFormat("m/d/Y");
      var dateString:String = "1/25/2008";
      var date : Date = formatter.parse(dateString);
      var dateFormatter : DateFormatter = new DateFormatter();
      dateFormatter.formatString = "MMMM D, YYYY";
      trace(dateFormatter.format(date));

      The output is "January 25, 2008".

      However, if you change the date to "2/25/2008", the output is "March 25, 2008."

      I'd prefer seeing the months OTHER than January adjusted to use a 1-based array (so 2 is February, 3 is March, etc.) to make it easier to load data from an external file or text input or whatever, parse it in 1 line, and return an accurate date object. With the zero based array I need to adjust the months. Either way you choose to implement this it should be consistent across all months.

      Attachments

        Activity

          People

            adobejira Adobe JIRA
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: