Skip to main content
April 9, 2009
Answered

WDDX (de)serializes dateTime with wrong DST rules?

  • April 9, 2009
  • 1 reply
  • 5461 views

2006-Aug-20 00:00 is being translated to 2006-Aug-19 23:00.  That date was in Pacific Daylight Time (-7) but the result seems to be -8 (PST).

I created a Web Service in Lotus Domino 7 and consume it in Coldfusion 8.  I've always returned data to Coldfusion as strings and thought I'd try passing a dateTime.  My Java code uses a kludge to get the ISO8601 date right:

("sb_" = java.lang.StringBuffer; "s__" = java.lang.String; "ca_" = java.util.Calendar)

df_SimpleWddx = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssZ" );
s__Kludge = df_SimpleWddx.format( ca_Began.getTime() );

sb_Wddx.append( "<var name='dt_Began'><dateTime>" + s__Kludge.substring( 0, 22 ) + ":" + s__Kludge.substring( 22 ) + "</dateTime></var>" );

My Coldfusion code:

("dx_" = WDDX data; "st_" = Coldfusion structure)

<cfwddx action="wddx2cfml" input="#dx_BadDates#" output="st_BadDates" />

<cfdump var="#st_BadDates#" />

Seeing {ts '2006-08-19 23:00:00'} in <cfdump>, I changed my Java code to:

sb_Wddx.append( "<var name='dt_Began'><string>" + s__Kludge.substring( 0, 22 ) + ":" + s__Kludge.substring( 22 ) + "</string></var>" );
and got "2006-08-20T00:00:00-07:00" (which is correct).

Unless I'm totally lost, Domino (running JVM 1.4.2_11) is sending the date correctly but <cfwddx> isn't turning it into a dateTime correctly.  I'm running the Developer version of Coldfusion (on my local XP machine) and Coldfusion's JVM is 1.6.0_04.

Has anyone else fought this battle but won?

This topic has been closed for replies.
Correct answer tooMuchTrouble

Didn't catch that, Paul.  Try Caps Lock - my hearing isn't what it used to be.


sorry it was a test to show adobe that email replies w/quotes show up blank in

the forums.

i'll be submitting the wddx DST issue to adobe as a bug. in the meantime you'll

probably have to workaround it. i guess test if the date is in DST & adjust it

back once it's converted from wddx.

1 reply

April 10, 2009

In fewer words, what date do you get with this code? (Change the two red sevens to your current offset from GMT.)

<cfwddx action = "wddx2cfml"
        input  = "<wddxPacket version='1.0'><header/><data><dateTime>2006-08-20T00:00:00-07</dateTime></data></wddxPacket>"
        output = "s__WddxDate" />
<cfoutput>WDDX: #s__WddxDate#</cfoutput><br/>


<cfset df_Simple = CreateObject( "java", "java.text.SimpleDateFormat" ) />
<cfset df_Simple.applyPattern( "yyyy-MM-dd'T'HH:mm:ssZ" ) />
<cfoutput>Java: #df_Simple.parse( "2006-08-20T00:00:00-0700" )#</cfoutput>

I get:

WDDX: {ts '2006-08-19 23:00:00'}
Java: {ts '2006-08-20 00:00:00'}

Inspiring
April 12, 2009

this is from memory as the forums seem to have eaten my 1st reply:

i got a WDDX datetime parse error. when i sent a datetime from cf to WDDX & back again i get something like:

2009-4-15T10:29:53+7:0
{ts '2009-04-15 10:29:53'}

from this code (which was still on the dev box):

<cfwddx action = "cfml2wddx" input = #now()# output = "wddxText" useTimeZoneInfo="yes">
   
<cfoutput>#wddxText#</cfoutput>
<br>

<cfwddx action = "wddx2cfml"
        input  = "#wddxText#"
        output = "s__WddxDate" />

<cfoutput>#s__WddxDate#</cfoutput>
<br>

note the tz format, i think if you change your original format to include the minutes (the "+7:0" bits, i'm in thailand using indochina tz +7 UTC) you should be good to go. and before you ask, yes there are tz that use mnutes in their offsets.