//获取mysql中的数据,其中包括时间
@RequestMapping("/getmanagers")
@ResponseBody
public List getWorkOrders(HttpServletRequest request){
List workOrders=workOrdersService.getWorkOrders();
request.setAttribute("workOrders", workOrders);
return workOrders;
}
------------------------------------------------------------------------------------------------------------
当获得数据时,后台debug可发现,获得的时间是一个13位的数字。这个就是java的时间戳
当运用到Extjs里的时候,要借用js的时间转换
columns: [{
text: 'ID',
dataIndex: 'id',
width:50,
editor: {
readOnly:true
}
}, {
// text: '故障时间',
header:'故障时间',
dataIndex: 'failuretime',
width:180,
renderer:function(value){
return new Date(parseInt(value)).toLocaleString();
}
}, {
text: '故障地点',
dataIndex: 'failureaddress',
width:200,
editor: {
allowBlank: false
}
}, {
header: '维修时间',
dataIndex: 'repairtime',
width:180,
// editor:new Ext.form.DateField({
// format:'Y-n-j',
// minValue:'1990-12-14'
// }),
renderer:
function(value){
return new Date(parseInt(value)).toLocaleString(); //13位时间戳转换为2013年10月11日 11:12:23格式
}
}, {
text: '维修人',
width:200,
dataIndex: 'maintenanceman',
editor:{
allowBlank:true
}
}, {
text: '完成情况',
width:100,
dataIndex: 'completion',
editor:{
allowBlank:true
}
}, {
text: '故障内容',
width:200,
dataIndex: 'failurecontent',
editor:{
allowBlank:true
}
}], 其中红色的部分为Extjs转换13位时间戳为日期的方法。这是我的笔记。下次忘了来看看