6 Replies Latest reply on Dec 4, 2012 7:28 AM by Tony_Stocks

    Problem with DateTimeFormatter and LocaleID.DEFAULT

    fdn64

      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.

       

      frmtDateOnlyspark.formatters.DateTimeFormatter (@48396c81)
      [inherited]
      actualLocaleIDName"en-GB"
      dateStyle"short"
      dateStyleOverride"short"
      dateTimePattern"M/d/yy"
      dateTimePatternOverridenull
      errorTextnull
      _errorTextnull
      fallbackFormatternull
      g11nWorkingInstanceflash.globalization.DateTimeFormatter (@48163c29)
      _g11nWorkingInstanceflash.globalization.DateTimeFormatter (@48163c29)
      lastOperationStatus"noError"
      resourceManagermx.resources.ResourceManagerImpl (@463f83c1)
      timeStyle"none"
      timeStyleOverride"none"
      useFallbackfalse

       

      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.