我有一个@Entity
with 字段
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_on", nullable = false)
private Date createdOn;
将时间戳保存为
+----+------+------------+-------+--------------------------+---------------------+---------------------+------+
| id | name | type | units | description | created_on | retired_on | core |
+----+------+------------+-------+--------------------------+---------------------+---------------------+------+
| 1 | v1 | Double | u1 | created via migration | 2013-01-14 13:15:19 | NULL | 1 |
| 2 | v2 | String | u2 | created via migration | 2013-01-14 13:15:19 | NULL | 1 |
| 3 | v3 | BigDecimal | u3 | created via migration | 2013-01-14 13:15:19 | NULL | 0 |
| 27 | v4 | String | u4 | created with web service | 2013-01-15 10:37:30 | 2013-01-15 11:27:48 | 1 |
+----+------+------------+-------+--------------------------+---------------------+---------------------+------+
当我检索数据时,我得到 Date 对象,其值如下
"createdOn": 1358198119000,
"createdOn": 1358198119000,
"createdOn": 1358198119000,
"createdOn": 1358275050000,
如何将它们转换回带有时间戳'2013-01-15 10:37:30'
的日期,而不是数字1358198119000
?