| Suppose you have:
@RevisionTimestamp
@Temporal (TemporalType.TIMESTAMP)
private Date timestamp;
The timestamp should be saved in the database as UTC, but instead it is saved as a Local time (that depends on the local timezone of the computer). This makes no sense, since a timezone change (or the same software running on different countries) will result in different time references, and incompatible software. Time should always be in UTC in the database, because the client software may convert it to Local time, when necessary. The opposite is not always true (some other client accessing the same database may be in a different timezone, and there is no way of knowing). The workaround, at the moment, is to add this to the class anotated as @RevisionEntity:
static {
TimeZone.setDefault(TimeZone.getTimeZone(ZoneId.of("UTC")));
}
However, this workaround may have undesirable side-effects. Note 1: In
HHH-10827 - The field annotated with @RevisionTimestamp should accept type java.time.LocalDateTime Open I ask for Hibernate to accept the timestamp in java.time.LocalDateTime, which already contains timezone info, and naturally should result in correct timestamps when saved to the database. Note 2: The original timestamp from DefaultRevisionEntity uses "long" as timestamp, and I don't know and haven't tested if this is mapped to UTC or not. If not, it should be fixed as well:
@RevisionTimestamp
private long timestamp;
|