实体类对象转Json时格式化时间

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature; 


//wechatOrder为实体类对象
String s = JSONObject.toJSONStringWithDateFormat(wechatOrder, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteDateUseDateFormat);  

JSONObject jsonObject = JSONObject.parseObject(s);
 //格式化前
 { 
    "updateTime": "2020-03-19T11:09:27"
 }



//格式化后
 {
    "updateTime": "2020-03-19 11:09:27"
 }

 

你可能感兴趣的:(java)