views:

381

answers:

1

How do I retrieve the locale-specific date format string in Flex / ActionScript 3? I am unable to find a method to return the actual format string (that which specifies the date format) based on the current locale. I am asking this question because I was hoping to find a way to convert a String to a Date based on the current SHORT date format for the locale. Java allows one to call:

DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT, locale)

to retrieve an instance of DateFormat that formats according to the SHORT format based on the locale.

Does similar functionality exist in Adobe Flex (ActionScript 3) 3? If not, is there a reliable third party library that exists for this?

A: 

Yeah I have to say Java is better with dates - you set the locale and automatically your dates are outputted correctly! I can't seem to find such a facility in Flex.

In order to output your dates correctly for each locale I think you have to do what is written in this article: http://livedocs.adobe.com/flex/3/html/help.html?content=l10n_1.html. Maybe you should do this, and in the same class just make these strings which you've pulled from the locale file available to the rest of your app, then you'll be able to operate on them.

Otherwise perhaps this guy's library will help you? I'm not sure. http://flexoop.com/2008/12/flex-date-utils-date-and-time-format-part-ii/

Fletch