fastTime从后台传过来显示格式的处理

1、可以在控制台用syso查看

QuestionFeedbackView qfv = on_LineManageService.getBringupHead(projectNo);//qfv是一个内含两个 时间属性 的对象
// 输出格式: 2015-1-27 或 Jan 27, 2015
Date begin = qfv.getActualbegin();
Date end = qfv.getActualend();
String actualBegin = DateFormat.getDateInstance(DateFormat.MEDIUM).format(begin);//以字符串的形式输出  输出格式: 2015-1-27
String actualEnd = DateFormat.getDateInstance(DateFormat.MEDIUM).format(end);

2、通过ajax回显到页面

success : function(result) {//result.data为上述qfv
if (result.isSuccess) {
var begin = new Date(parseInt(result.data.actualbegin));
var end = new Date(parseInt(result.data.actualend));
$("#clientmag").text(result.data.clientManager);
$("#productmag").text(result.data.productManager);

//$("#begintime").text(result.data.actualbegin.format("yyyy-MM-dd"));//页面显示会报错

//$("#begintime").text(result.data.actualbegin);//页面显示为一串数字,即fastTime
$("#begintime").text(begin.format("yyyy-MM-dd"));//页面显示为: 2015-1-27格式
$("#endtime").text(end.format("yyyy-MM-dd"));
}
},

上述为两种从后台传到前端的日期格式处理,后续碰到从前端传到后端存储的再加

原文地址:https://www.cnblogs.com/zz-3m23d-begining/p/6747908.html