tags:

views:

47

answers:

2

I understand that one can use local-specific ResourceBundles in combination with DateFormatters to format dates according to locale. However this is a manual process - is there an automatic way to do this or to set a default for the application?

In Java for example, all your dates will automatically appear in dd/mm/yy or mm/dd/yy format simply by setting the locale. In Flex, a default date output will always be in US format unless manually formatted otherwise. I'm looking for a way to get closer to the Java functionality.

A: 

Look at toLocaleString and toLocaleTimeString

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Date.html#toLocaleString()

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Date.html#toLocaleTimeString()

www.Flextras.com
Thanks for that, handy but not 100% there. Take for example a DateTimeAxis, by default it might figure out to format your dates mm/dd/yy, which in itself is very handy. I would like the same but formatted dd/mm/yy. I guess I'll just have to write some labelFunctions which grab the locale strings like this guy says http://livedocs.adobe.com/flex/3/html/help.html?content=l10n_1.html.
Fletch
@Fletch; In your original question, you said that "Flex will always use US Format unless manually formatted." I'm not sure about the standard date functions, but the locale method I specified should refer tot he locale of the player, which should not always be US based. Is there any country that formats dates using dd/mm/yy? It sounds to me like you are going to need to format them manually.
www.Flextras.com
Basically every locale except en_US formats dates with the day before the month. Your method actually works very well if what you want is something like "3 Sep 2010".In my case I want 3/9/10 and there's no method for that.
Fletch
I meant: Basically every locale except en_US formats dates with the day before the month. Your method actually works very well if what you want is something like "3 Sep 2010", so it will come in handy in other cases. In my case the DateTimeAxis is, without any config, smart enough to figure out whether it should show a time, a date or a combination based on what range the axis covers (pretty cool). I can override that but I wanted to leverage that "automatic figuring it out" with only the slight modification that if it shows a mmddyy type string, then it shows it in the dd/mm/yy format.
Fletch
@Fletch I'm no localization expert, but I thought most locales use yyyy/mm/dd; whereas the US uses mm/dd/yyyy . Which ones put the day first? Nevertheless, you should be able to extend the DateTimeAxis to reformat days. I would expect it to be relatively easy, but it depends on how much of the class is private.
www.Flextras.com
Yes that's an idea, thanks. Who puts the day first? en_GB, en_AU, de_DE, fr_FR, es_ES etc. The year-first paradigm is a more modern internet-thing to counter the confusion of the meaning of strings like 3/4/2010.
Fletch
You're right; day first seems pretty common according to this wikipedia country list:. http://en.wikipedia.org/wiki/Calendar_date#List_of_the_world_locations_by_date_format_in_use . However, year first won't solve said problems. Because "2010/3/4" presents the same question. Is it March 4th? Or April 3rd? Year First does sort by date order as strings, though.
www.Flextras.com
A: 

It is a feature of Flash Player 10.1 placed in flash.globalization package

The flash.globalization package in Flash Player: Cultural diversity without complexity

JabbyPanda