/// <summary>
/// object转化为json时Datetime类型格式转化
/// </summary>
/// <returns></returns>
private static IsoDateTimeConverter SetJsonDateTimeFormate()
{
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm";
return timeConverter;
}
//将object转化成json格式
private string GetConvertEntityJson(string id)
{
string json = "";
BPileinfo bllPileinfo = new BPileinfo();
MES_YD_PILEINFO pileInfo = bllPileinfo.GetPileinfoInfo(id);
json = JsonConvert.SerializeObject(pileInfo, SetJsonDateTimeFormate());
return json;
}

本文介绍了一个将对象转换为JSON格式的方法,并特别关注了如何处理和格式化对象中的Datetime属性,确保其符合特定的日期时间格式。
&spm=1001.2101.3001.5002&articleId=8080607&d=1&t=3&u=09b5999e6dcf4bd9a26f887959cacba7)
6123

被折叠的 条评论
为什么被折叠?



