JQGrid顯示TimeStamp時間格式

使用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;
    }


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章