2

according to the coldfusion docs SerializeJSON converts Dates to strings which can easily be parsed by JavaScript Date objects. I just serialized a query and JavaScript could not parse the Date columns because the name of the month was serialized local specfic returning Mai, what is not understood by JavaScript. Javascript only accepts english month names. Do I now - as I just did - have to replace the local specific month name manually with it's english translation to easily parse the string to a JavaScript Date object?

Best, Bernhard

Bernhard Döbler
  • 1,960
  • 2
  • 25
  • 39

3 Answers3

1

You could try and deal with this on the server by using setLocale('en_us') to force English language versions of your query when serialised - not ideal but it might get the job done. I think this can be set per request. See info here: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fa3.html

Hope that helps.

Ciaran Archer
  • 12,316
  • 9
  • 38
  • 55
  • Hello, thank you very much for your reply. I read about setting the locale on the web http://coldfusion.tcs.de/coldfusion-locale-problem-with-serializejson-and-date-fields/ I'm not satisfied with that solution, bcause I thus can no longer use functions like LSNumberFormat(...) etc. – Bernhard Döbler May 03 '11 at 19:24
  • 1
    Can't you set the locale and then reset it back immediately after serializing the JSON? – Todd Sharp May 05 '11 at 14:17
  • Todd, I have not tried yet but studied the doc. It actually sounds possible. Since the serialization exclusivly happens in the OnCFCRequest-Memthod of the Application.cfc there's only one place where some code is needed. Thanks for your reply. – Bernhard Döbler May 09 '11 at 19:10
1

This answer to another question suggests that perhaps you could use datejs and then use the appropriate localization to parse your strings natively rather than in English.

Community
  • 1
  • 1
Dave DuPlantis
  • 6,378
  • 3
  • 26
  • 30
0

I have a solution

In the coldfusion administrator add this -Duser.language=en -Duser.region=US to the JVM agruments. (And restart the service) You tell the JVM engine not to use the machine locale but to use the 'normal' english locale.

When you use SerializeJSON after the change it will generate dates with the enlish month names.

I haven't found any unwanted side effects with this change.

birdy1980
  • 317
  • 1
  • 10