JQGrid顯示TimeStamp時間格式
阿新 • • 發佈:2019-01-22
使用JQGRID展現前臺資料,JAVA實體類中的TimeStamp型別資料序列化後變為類似
1451288297841
的資料,對時間函式熟悉的碼農們都知道這是返回1970年1月1日至今的毫秒數 直接上程式碼
colNames:['產品編號','產品名稱','產品分類','產品價格','產品描述','建立時間'], colModel:[ {name:'id',index:'id', width:60,align:'center'}, {name:'productName',index:'productName', width:40,align:'center'}, {name:'productType',index:'productType',formatter:function(cellvalue, options, row){return productCategory[cellvalue]},width:40, align:'center'}, {name:'productPrice',index:'productPrice',width:40, align:'center'}, {name:'productDetail',index:'productDetail',width:60, align:'center'}, {name:'createTime',index:'createTime', width:60, formatter:function(cellvalue, options, row){return new Date(cellvalue).toLocaleString()}, align:'center'} ]
重點是這個:
new Date(cellvalue).toLocaleString()
對應實體類片段:
@Column(name = "CREATE_TIME", length = 11)
public Timestamp getCreateTime() {
return this.createTime;
}
public void setCreateTime(Timestamp createTime) {
this.createTime = createTime;
}