tags:

views:

99

answers:

2

I'm using a WSDL that expects a DateTime parameter for one of the methods. When .NET serializes my call, it creates a date parameter like this:

2010-1-1T10:00:00.00

This looks like the serializer is using a date format of "s". I need a different format, namely one with the timezone offset:

2010-1-1T10:00:00.00 -4:00

How do I specify the date format I want the serializer to use? (C# or VB.NET)

+1  A: 

If the timezone offset is for your current timezone, you should check that your DateTime instance has its Kind property set to DateTimeKind.Local. If not, you can force it as follows:

DateTime myDateTime;
...
myDateTime = myDateTime.SpecifyKind(myDateTime, DateTimeKind.Local);
Joe
Thanks - this worked perfectly.
Dave C
A: 

Usually this would be done by passing Time / Date in the UTC (Universal Time Coordinated) format... meaning: Worldtime and putting the timezone (if needed) in a seperate parameter.

See: http://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime%28VS.71%29.aspx

Steav
That's a fine idea, but my question is HOW do I get the serializer for SOAP calls to use some format instead of its default format?(In any event, the service I'm calling doesn't accept that format - I tried it using SoapUI)
Dave C