我要如何改变一个.NET SOAP请求的日期格式? [英] How do I change the Date Format of a .net SOAP request?

查看:157
本文介绍了我要如何改变一个.NET SOAP请求的日期格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是WSDL希望获得日期时间参数的方法之一。当.NET连载我的电话,它会创建一个日期参数是这样的:

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

2010-1-1T10:00:00.00

这看起来像串是用S的日期格式。我需要一个不同的格式,即一个具有时区偏移:

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

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

我如何指定我想要的序列化使用的日期格式? (C#或VB.NET)

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

推荐答案

如果该时区的偏移是您当前的时区,你应该检查你的DateTime实例都有属性设置为 DateTimeKind.Local 。如果没有,你可以强制它如下:

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

这篇关于我要如何改变一个.NET SOAP请求的日期格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆