Newtonsoft.Json 时间格式化

Posted 瘋孑

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Newtonsoft.Json 时间格式化相关的知识,希望对你有一定的参考价值。

时间序列化经常多个T:“2017-01-23T00:00:00”

解决方案:

日期格式化输出,指定IsoDateTimeConverter的DateTimeFormat即可

  IsoDateTimeConverter timeFormat = new IsoDateTimeConverter();

    timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
  JsonConvert.SerializeObject(dt, Formatting.Indented, timeFormat)

以上是关于Newtonsoft.Json 时间格式化的主要内容,如果未能解决你的问题,请参考以下文章