我需要将毫秒精度时间戳存储到数据库中。
我通过谷歌搜索做了很多尝试。但每次尝试都失败了。 所有这些都截断了毫秒,只返回秒。
我的尝试出了什么问题?
在这里,我列出了我尝试过的内容。
//环境
JPA 2.1
Hibernate 5.2.10
MySql 5.5.28
// Failed to get milliseconds
@Temporal(TemporalType.TIMESTAMP)
private java.util.Date updatedAt;
// Failed to get milliseconds
private java.sql.Timestamp updatedAt;
// Failed to get milliseconds
@Column(columnDefinition = "TIMESTAMP")
private java.sql.Timestamp updatedAt;
// Failed to get milliseconds
@Column(columnDefinition = "TIMESTAMP (3)")
private java.sql.Timestamp updatedAt;
// Failed to get milliseconds
@Column(columnDefinition = "TIMESTAMP (6)")
private java.sql.Timestamp updatedAt;
// Failed to get milliseconds
// with converter https://github.com/leapfrogtechnology/vyaguta-commons/blob/master/src/main/java/com/lftechnology/vyaguta/commons/jpautil/LocalDateTimeAttributeConverter.java
private LocalDateTime updatedAt;
// Failed to get milliseconds
@Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
private org.joda.time.DateTime updatedAt;