Question

I am accessing a webservice in .net which returns a dataset.

Looking at the xml from the webservice it shows a date as follows

2012-11-16T00:00:00-05:00

My computers timezone is GMT+1, you can see the date from the XML has the -5

I am using a webreference in VS2005 which gives me a dataset.

When I look at the date from the dataset it says it is 05:00

I was expecting 00:00 value and am unsure the proper way to convert.

I could simply subtract 5 hours, but not sure that will hold when daylight savings changes again.

Ive done a lot of googling and found similar problems when using datareader and how to fix it, but noone talking about what to do when it gets serialized into an entire dataset.

Was it helpful?

Solution

The XML is providing the local value, which is 2012-11-16T05:00:00Z. It sounds like the deserialization is then converting that into a DateTime in UTC... check the Kind property of the DateTime you've got... if it's Utc then it all makes sense, and you're getting the correct instant in time represented in the XML.

It's not clear what you're expecting, or what's posting the data, or what value you really need from it. If you can change the deserialization code to use DateTimeOffset instead of DateTime, that would preserve both pieces of information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top