2 Replies Latest reply on Sep 27, 2011 1:28 PM by PierreSolutions

    Missing parsing of locale-formatted dates in Flex

    Kazaak549879 Level 1

      I'm missing a locale-specific date parsing in Flex.


      While it's easy to format a date/time to any format by providing a pattern like "DD/MM/YYYY" and using mx.formatters.DateFormatter.

      DateFormatter has parseDateString, which is static and ignores the format. The function can correctly parse US-formatted dates only, as many developers have noted.


      In SDK 4 it is advised to use spark.formatters.DateTimeFormatter, but the class has no parsing functionality at all.


      No question it's not a simple task, but some other competing frameworks have support for that since version 1, e.g. http://msdn.microsoft.com/en-us/library/kc8s65zs.aspx


      Is there at least a good 3rd party component, which can do it properly?



        • 1. Re: Missing parsing of locale-formatted dates in Flex
          Kazaak549879 Level 1

          currently I'm working around the problem by avoiding parsing and giving the user no option to type the date, providing DateField and DateChooser instead and formating with DateField.labelFunction.


          Note that the standard mx.controls.DateField has it's own parseFunction() and formatString(), which are better to set to null if you care about non-US formats.

          Internally the component will try to parse text representation of the date, and may fail with the built-in function. If these properties are set to null, DateChooser will work with DateField's date value directly instead.


          Also I've adopted somebody's utility for parsing date, fixed bugs and extended functionlity to handle at least some additional formats.

          If there is interest I can post the code.

          • 2. Re: Missing parsing of locale-formatted dates in Flex
            PierreSolutions Level 2

            There is interest. Please post the code.