6 Replies Latest reply on Jun 2, 2006 11:38 AM by poonamsheth

    Formatting Dates

    Caps1984
      I've been working on an app for my company using Australian dates (DD/MM/YYYY) rather than the default (MM/DD/YYYY). I have used the recommended method of declaring a DateFormatter, creating a function to perform the formatting and assiging it to the DateField (see code).

      On first glances it appears to be functioning correctly, but if you choose a date with a day of 12 or less (eg 5th of April, 2006 or 05/04/2006 in Australian format) after the focus is moved from the DateField the format reverts to the default format and in effect changes the date (4th of May, 2006 04/05/2006 in Australian format). Has anyone else experienced this problem or know how to resolve this issue?

      Thanks in advance,

      Pete

        • 1. Re: Formatting Dates
          GordonSmith Level 4
          Nice find! I've filed it as a bug.
          • 2. Re: Formatting Dates
            GordonSmith Level 4
            Oops... not a bug after all. If you specify a labelFunction, you're supposed to also specify a parseFunction for DateField. The ASDoc for labelFunction says "If you allow the user to enter a date in the text field of the DateField control, and you define a formatting function using the labelFunction property, you should specify a function to the parseFunction property that converts the input text string to a Date object for use by the DateField control, or set the parseFunction property to null." In Beta 2 you could use the DateField method stringToDate() as your parseFunction, but we mistakenly made that function private in Beta 3. However, the simpler solution is set neither labelFunction nor parseFunction but instead simply set formatString="DD/MM/YYYY" on the <mx:DateField>. That format will be used both for formatting and for parsing.
            • 3. Formatting Dates
              Caps1984 Level 1
              Great! Thanks very much for your help - a good start to a Monday morning!

              Edit: On a 2nd look, formatString is not a valid attribute for DateField, at least in Beta 3. But the problem is resolved if you set parseFunction to "null" as specified above.

              Thanks again for your help!
              • 4. Re: Formatting Dates
                GordonSmith Level 4
                I didn't realize that the 'formatString' property is a recent addition to DateField. Look for it in the GMC candidate.
                • 5. Re: Formatting Dates
                  Caps1984 Level 1
                  GMC Candidate? Is that the next public release?
                  • 6. Re: Formatting Dates
                    poonamsheth
                    Whats GMC Candidate? [Want to knoe for knowledge purpose]