开发者

ASP.NET + JSON + C#.NET or VB.NET: Problem deserializing date time with JSON WCF WebService

I'm getting datetime in JSON format as -

"\/Date(1261413600000+0530)\/"

From code behind,开发者_Python百科 I'm using DataContractJsonSerializer.ReadObject method to deserialize data.

Converted data time is not correct.

How to parse correct JSON date time from code behind?


You can use a regular expression to get the number which is the number of ticks since 1/1/1970. Then you can get the date using the following:

DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
DateTime dt = unixEpoch.AddSeconds(Convert.ToDouble(ticks));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜