开发者

How to convert a univeral date string to local time

I'm trying to read a universal date string and convert it to local time. For开发者_如何转开发 example: read the string "2002-05-01T15:20:15-08:00" and convert it to the local time equivalent.


IFormatProvider culture = new CultureInfo("en-US", true);    
DateTime utcDate = DateTime.Parse("2002-05-01T15:20:15-08:00", culture, DateTimeStyles.AssumeUniversal);

(untested) Taken from here.


You can use the DateTime.ToLocalTime method: http://msdn.microsoft.com/en-us/library/system.datetime.tolocaltime.aspx

Basically something like: DateTime localTime = utcTime.ToLocalTime();


var result = DateTimeOffset.Parse(myString).ToLocalTime();

?


My suggestion would be to use SOA or BPEL. I don't know what they are but I heard they can do everything without even really having to think about the problem or even understanding how the architecture works.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜