C#处理返回JSON日期(YYYY-MM-DD HH:MM:SS):
public string apiHandle(){
return ToFormatJson(JsonConvert.SerializeObject(lo_return));
}
private string ToFormatJson(string jsonStr)
{
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
Regex reg = new Regex(@"\\/Date\((-*\d+)\)\\/");
var newjson = reg.Replace(jsonStr, matchEvaluator);
return newjson;
}
private string ConvertJsonDateToDateString(Match m)
{
string result = string.Empty;
DateTime dt = new DateTime(1970, 1, 1);
dt = dt.AddMilliseconds(long.Parse(m.Groups[1].Value));
dt = dt.ToLocalTime();
result = dt.ToString("yyyy-MM-dd HH:mm:ss");
return result;
}