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.setStyle("locale",this.locale); | ||||
| this.frmtDateOnly.timeStyle = DateTimeStyle.NONE; | ||||
| this.frmtDateOnly.dateStyle = DateTimeStyle.SHORT; | ||||
| this.frmtTimeOnly = new spark.formatters.DateTimeFormatter() | ||||
| this.frmtTimeOnly.setStyle("locale",this.locale); | ||||
| this.frmtTimeOnly.timeStyle = DateTimeStyle.SHORT; | ||||
| this.frmtTimeOnly.dateStyle = DateTimeStyle.NONE; | ||||
| this.frmtDateTime = new spark.formatters.DateTimeFormatter() | ||||
| this.frmtDateTime.setStyle("locale",this.locale); | ||||
| 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.
| frmtDateOnly | spark.formatters.DateTimeFormatter (@48396c81) | ||
| [inherited] | |||
| actualLocaleIDName | "en-GB" | ||
| dateStyle | "short" | ||
| dateStyleOverride | "short" | ||
| dateTimePattern | "M/d/yy" | ||
| dateTimePatternOverride | null | ||
| errorText | null | ||
| _errorText | null | ||
| fallbackFormatter | null | ||
| g11nWorkingInstance | flash.globalization.DateTimeFormatter (@48163c29) | ||
| _g11nWorkingInstance | flash.globalization.DateTimeFormatter (@48163c29) | ||
| lastOperationStatus | "noError" | ||
| resourceManager | mx.resources.ResourceManagerImpl (@463f83c1) | ||
| timeStyle | "none" | ||
| timeStyleOverride | "none" | ||
| useFallback | false |
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.
Hi,
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.
Thanks,
harish
This is a device issue not a simulator one. Thanks for looking into it.
In addition:
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.
North America
Europe, Middle East and Africa
Asia Pacific