0 Replies Latest reply on Oct 22, 2008 12:00 PM by ckryanco

    Inconsistent date/number formatting in a globalized ColdFusion application

    ckryanco Level 1
      Hello. We're working on a globalized ColdFusion application using the icu4j java library, but are getting inconsistent results from date and number formatting. In some locales (mostly the western locales plus Arabic), the result is fine -- but in others (like Chinese), we're seeing a mixture of western and Chinese characters.

      We've expanded a script by Paul Hastings to do this. Here's what we're using:

      <!--- icu4j Locale Handling --->
      <cfsilent>
      <cfscript>
      userULocale=createObject("java","com.ibm.icu.util.ULocale");
      userULocale.init("#GetAccountData.Locale#");

      icu4jDateFormat=createObject("java","com.ibm.icu.text.DateFormat");
      fullFormat=javacast("int",0);
      longFormat=javacast("int",1);
      mediumFormat=javacast("int",2);
      shortFormat=javacast("int",3);
      icu4jDF=icu4jDateFormat.getDateInstance(fullFormat,userULocale);
      icu4jDF_Long=icu4jDateFormat.getDateInstance(longFormat,userULocale);
      icu4jDF_Medium=icu4jDateFormat.getDateInstance(mediumFormat,userULocale);
      icu4jDF_Short=icu4jDateFormat.getDateInstance(shortFormat,userULocale);
      icu4jDF_MonthAndYear=icu4jDateFormat.getPatternInstance("MMMM yyyy", userULocale);
      icu4jDF_YearOnly=icu4jDateFormat.getPatternInstance("yyyy", userULocale);
      icu4jDF_ReportFormat=icu4jDateFormat.getPatternInstance("EEEE MMM dd", userULocale);

      icu4jNumberFormat=createObject("java","com.ibm.icu.text.NumberFormat");
      icu4jNF=icu4jNumberFormat.getInstance(userULocale);

      </cfscript>
      </cfsilent>

      Once that script has executed, we're using ColdFusion code like this to display the dates/times:

      (c)<cfoutput>#icu4jDF_YearOnly.format(now())#</cfoutput>
      #icu4jNF.Format(JavaCast('bigdecimal',TypeCount))#
      #icu4jDF_MonthAndYear.format(RequestedMonth)#
      #icu4jNF.Format(JavaCast('bigdecimal',MinutesLeft))#

      For about half of the locales we've tested this works perfectly, but other times it only partially formats the dates/times in the local character set with western numbers/characters mixed in.

      Are we missing something to consistently format numbers/dates in all of the locales?

      Thank you!