SpringBoot学习笔记(4):处理前端JSON返回的日期的格式
问题描述
前端页面显示的时间为毫秒格式,不利于直观显示!
解决方法1——后端解决
public class Flow {
@JsonFormat(pattern = "yyyy-MM-dd", timezone="GMT+8")
private Date flow_date;
.....
}
解决方法2——JS处理
function crtTimeFtt(val, row) {
if (val != null) {
var date = new Date(val);
return date.getFullYear() + ‘-‘ + (date.getMonth() + 1) + ‘-‘ + date.getDate();
}
}