序列化JSON时时间类型处理-IsoDateTimeConverter

public static string MyEncode(object o)
{
    if (o == null || o.ToString() == "null") return null;
    if (o != null && (o.GetType() == typeof(String) || o.GetType() == typeof(string)))
    {
        return o.ToString();
    }
    IsoDateTimeConverter dt = new IsoDateTimeConverter();
    dt.DateTimeFormat ="yyyy'-'MM'-'dd'T'HH':'mm':'ss";
    return JsonConvert.SerializeObject(o, dt);
}

 

posted @ 2018-10-12 09:05  skybirdzw  阅读(1160)  评论(0)    收藏  举报