06. November 2009

While playing around with CouchDB, ColdFusion and SerializeJSON i found that the SerializeJSON does not honor the SetLocale setting. It will use the "Java Default Locale" which is set for the JRE.

So if your Windows installation is German, you will have a DE_de locale.

Now if you us SerializeJSON for a date you will get a date like "März, 21. 2009". Not really good to use this in another DB.

To set the ColdFusion Java Default Locale to en_US you can supply a command line switch

-Duser.language=en -Duser.region=US

Java default locale

 

3 comments for ColdFusion locale problem with SerializeJSON and date fields
  1. jaro
    Thanks, a very good tip!
    28.04.2010 12:04
  2. Thanks for the great tip. I'm trying to change the locale "on the fly", as I can't change the locale in the JVM args at the server, but it's not working. I'll try a third party JSON library to see if I can get this fixed, but it's truly annoying...
    28.07.2010 16:07
  3. As a note, I've managed to get things working here by using:
    locale = CreateObject("java", "java.util.Locale")
    locale = locale.init("en", "US")
    locale.setDefault(locale)
    serializeJSON(variable)
    locale = CreateObject("java", "java.util.Locale")
    locale = locale.init("pt", "BR")
    locale.setDefault(locale)
    In my case, as I can't change the server configuration, this was the only thing that worked.
    28.07.2010 17:07
Comments: Write a comment