开发者

How do I change the Date Format of a .net SOAP request?

I'm using a WSDL that expects a DateTime parameter for one of the methods. When .NET serializes my call, it c开发者_开发问答reates 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)


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);


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜