使用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; }
JQGrid显示TimeStamp时间格式
最新推荐文章于 2024-07-23 15:20:31 发布