我以格式接收服务器的日期
[{"date":"2016-12-26T00:00:00+08:00"},
{"date":"2016-12-27T00:00:00+08:00"},
{"date":"2016-12-28T00:00:00+08:00"},
{"date":"2016-12-29T00:00:00+08:00"}]
我尝试用jarray.parse方法来解析它们。问题是:方法将日期修改为莫斯科TZ(在我的PC上设置)。因此,解析后,日期看起来像
"date": "2016-12-25T19:00:00+03:00"
"date": "2016-12-26T19:00:00+03:00"
"date": "2016-12-27T19:00:00+03:00"
的问题是:是否有可能防止修改日期?
var s = "['2016-05-10T13:51:20Z', '2016-05-10T13:51:20+00:00']";
using (JsonReader jsonReader = new JsonTextReader(new StringReader(s))) {
jsonReader.DateParseHandling = DateParseHandling.None;
var array = JArray.Load(jsonReader);
foreach (var item in array) {
var itemValue = item.Value<string>();
Console.WriteLine(itemValue);}
}
输出:
2016-05-10T13:51:20Z
2016-05-10T13:51:20+00:00