Copy link to clipboard
Copied
Hi
I keep getting an error when trying to parse a date using LSParseDateTime on a CF7 server. If I test the same code locally (CF8 developer) it works fine.
This is the code:
<cfset temp = SetLocale("English (UK)")>
<cfset tdate = "Wed, 26 Aug 2009 21:10:11 +0000">
<cfoutput>
Locale = #GetLocale()#
<br />
IsDate #IsDate(tdate)#
<br />
Parse #ParseDateTime(tdate)#
<br />
LS Parse #LSParseDateTime(tdate)#
</cfoutput>
The code gives the error
Thanks
Paul
Copy link to clipboard
Copied
I don't have a CFMX7 server to test on, so cannot verify anything I suggest before suggesting it I'm afraid.
What happens if you lop the "Wed, " off?
--
Adam
Copy link to clipboard
Copied
"Wed, 26 Aug 2009 21:10:11 +0000" fails on both cf8 & cf9 for my servers using
locale "en_US". it works when i set the locale to "en_GB", so i guess that's the
difference between your cf8 & cf7 servers?
Copy link to clipboard
Copied
Hi Paul
Thanks for checking on your server.
I had a look at the Java locale settings in the CF Admin for both machines:
CF7 is "en_US" (not working)
CF8 is "en_GB" (working)
Looks like you could be onto something. How can I change the local to "en_GB" on the CF7 server?
Thanks
Paul
Copy link to clipboard
Copied
first better check whether you should be changing the server's locale...you can
just do a setLocale("en_GB") on the pages that need it or in the
application.cfm/cfc to make cf use en_GB w/out bothering the rest of the box.
if you do go ahead then find you jvm.config & add
-Duser.language=en -Duser.region=GB
to java.args. stop & restart the cf server service.
just note that you'll see some quirks (in cfdirectory, cfschedule, log files,
etc.) when you get datetime data from the OS if it's not the same locale as cf.
Copy link to clipboard
Copied
I tried using setLocale(“en_GB”) both on page and in application .cfm but no joy.
I then updated the config file but again it hasn't worked (checked the server settings in cf admin and it has updated)
They are both on IIS, could there be a server setting I need to change.
Also, in response to Adams question. Removing the "Wed" results in "No" for isDate, but both "ParseDateTime" and "LSParseDateTime" run but "LSParseDateTime" doens't take into account the any specified time difference
Copy link to clipboard
Copied
any of those should have worked, especially the setLocale() method. sure it's
cf7? if i recall correctly cf7 was the 1st version to accept java locale IDs,
otherwise your locale would be "English (UK)".
what does this show?
<cfscript> writeoutput("locale:=#getLocale()#<br>"); setLocale("en_GB"); x="Wed, 26 Aug 2009 21:10:11 +0000"; writeoutput("#lsParseDateTime(x)#<br>locale:=#getLocale()#");
</cfscript
Copy link to clipboard
Copied
also what version of your JDK?
i don't have cf7 any longer to test on either.
Copy link to clipboard
Copied
getLocale returns "English (UK)"
The JDK version in the CFadmin settings is showing as "Java Version 1.4.2_09 "
On the box, if you go to the Java console I get "1.6.0_01"
CF version is 7, standard edition
Copy link to clipboard
Copied
if the locale is getting set, then that should work. does this work?
<cfscript> test="Wed, 26 Aug 2009 21:10:11 +0000"; pattern="E, d MMM yyyy H:mm:ss Z"; l=createObject("java","java.util.Locale").init("en","GB"); dF=createObject("java","java.text.SimpleDateFormat").init(pattern,l); d=dF.parse(test); writeoutput("#d#"); </cfscript>
i'm trying to find a cf7 server to test but if it really is w/cf then you might
have to use the above to parse those datetimes (and it should work no matter the
locale).
btw only the JDK in cfadmin counts, its the one that cf uses. and you might look
into getting a newer JDK--not sure but i think any newer 1.4.2 will work w/cf7.
but check first!
Copy link to clipboard
Copied
i finally found a kind soul to test on a cf7 server & can confirm your findings.
i also skimmed the sun java bug parade & didn't see anything really related, so
i'm going to say its w/cf (though thinking about that date format i actually
wouldn't expect it to get parsed w/out some fiddling).
turn that cf+java snippet into a function & use that, you can skip the locale
bits altogether.