I have developed an application that runs on iOS, QNX and Android, that receives remote data via web services. Some of the data are Date, Time or DateTime.
I created a global class containing the formatters used to display the respective DateTime fields in the user's local date time format:
|public var frmtDateOnly:spark.formatters.DateTimeFormatter;|
|public var frmtTimeOnly:spark.formatters.DateTimeFormatter;|
|public var frmtDateTime:spark.formatters.DateTimeFormatter;|
|public function ViewStackGlobals():void|
|this.OS = Capabilities.os.substr(0,3);|
|this.locale = LocaleID.DEFAULT;|
|this.frmtDateOnly = new spark.formatters.DateTimeFormatter();|
|this.frmtDateOnly.timeStyle = DateTimeStyle.NONE;|
|this.frmtDateOnly.dateStyle = DateTimeStyle.SHORT;|
|this.frmtTimeOnly = new spark.formatters.DateTimeFormatter()|
|this.frmtTimeOnly.timeStyle = DateTimeStyle.SHORT;|
|this.frmtTimeOnly.dateStyle = DateTimeStyle.NONE;|
|this.frmtDateTime = new spark.formatters.DateTimeFormatter()|
|this.frmtDateTime.timeStyle = DateTimeStyle.SHORT;|
|this.frmtDateTime.dateStyle = DateTimeStyle.SHORT;|
Whilst on QNX the formatters have correct settings, and when using the format() method I get correct results, on Android it doesn't work (well on my HTC Desire HD that is).
The table below shows the debugger output. Whilst the actualLocaleIDName is correctly set to en-GB, the dateTimePattern is still the en-US format. As said before, the same does work for QNX, I have not tested this yet with iOS.
Maybe I'm doing something wrong. I assume - hopefully correctly - that their must be a way to use (receive) the user / device settings for date time formatting and that one doesn't require to have a configuration document per application that a user would need to set to likings.
I checked it in FB4.5 simulator for Android HTC Desire HD (Windows) and on mac FB4.5 simulator (HTC Incredible). For frmtdateOnly, I do see the correct patterm of dd/MM/yyyy (windows simulator, HTC Desire HD), Mac (HTC Incredible) on both. The actualLocaleID is correct;y shown as en-GB.
I did set the locale as en-GB in control panel regional language settings (win) and mac system language settings.
I need to check it on the actual device and see the problem. I will get back to you on this.
This is a device issue not a simulator one. Thanks for looking into it.
When assigning a desired date time pattern to DateTimeFormatter.dateTimePattern property, the property itself is not modified, but the dateTimePatternOverride property is set accordingly. HOWEVER, the latter has no effect whatsoever.
I solved my problem by using the mx formatters, but that is obviously not the desired solution.
I verified it on Google Nexus. Handling i-default does have a bug on android devices.Possible work around is if you can use the locale explicitly en-GB then the bug won't surface. We filed a bug against it for near future fix.