Converting ISO 8601 dateTime to TimeStampOffset

Forums for specific tips, techniques and example code
Jason
Posts: 10
Joined: Thu Sep 02, 2010 6:14 pm

Converting ISO 8601 dateTime to TimeStampOffset

Postby Jason » Thu Jul 19, 2012 2:52 am

I need to read an XML message from an MSMQ. This message contains dateTimes in the ISO 8601 format (see http://www.w3.org/TR/xmlschema-2/#dateTime for more information). For example: 12/01/2012 14:00 would be represented in the XML message as "2012-01-12T14:00:00.00+00:00". I then need to store this as a TimeStampOffset.

Does anyone have any experience of converting ISO 8601 dateTimes to Jade TimeStampOffset types?

murray
Posts: 144
Joined: Fri Aug 14, 2009 6:58 pm
Location: New Plymouth, New Zealand

Re: Converting ISO 8601 dateTime to TimeStampOffset

Postby murray » Thu Jul 19, 2012 2:13 pm

It's just string handling, isn't it? Or is there some tricky stuff involving the time zones?
I have code that parses the ISO format (without TZ offset) into a Jade TimeStamp. Would that be of any help to get you started?
Murray (N.Z.)

Jason
Posts: 10
Joined: Thu Sep 02, 2010 6:14 pm

Re: Converting ISO 8601 dateTime to TimeStampOffset

Postby Jason » Fri Jul 20, 2012 9:03 am

Thanks Murray, parsing is certainly an option. Before going down that track though, I thought I'd check to see if this problem had already been solved.

I suspect the timezone part will be a bit fiddly as TimeStampOffset is the UTC time plus the offset, whereas the ISO 8601 format is the local time plus the timezone. Extracting the date and time should be straightforward (split on the 'T' and cast to the appropriate type).


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 19 guests