Friday, August 22, 2008

dateTime deserialization in .Net

The problem:
We created a webservice in .Net to implement a contract with a supplier. Among other things, we receive dateTimes. These dateTimes represent a point in time in another country (for instance, an accident occurred at 15:00 in Spain).

What happens:
when we receive the message, the deserialization engine converts the dateTime to a DateTime, assuming local time. So, we get 14:00. All information about the original timezone is lost.

The solution(s):

  1. Change the WSDL to receive another parameter (timezone) -> NOT AN OPTION. We don't own the contract.
  2. Add a new table and code on our side so we can compute the timezone ourselves, according to the original country.
  3. Guess the correct timezone
  4. Implement the webservice in another platform, like Java (deserializes dataTime to java.util.Calendar).

If you have other solutions, please give me a note...

1 comment:

Mário Romano said...

Sorry, no much help from here. Just a link I keep stumbling uppon but consistently fail to follow. Coding Best Practices Using DateTime in the .NET Framework: http://msdn.microsoft.com/en-us/library/ms973825.aspx. Yes, I know, you surely know this one...

PS: why do you want to write the client proxy on another platform - other then being rigthfully pissed with .NET? :)