I noticed that 31-12-2015 (13f476b) you changed storing of jv_commit.commit_date from local timestamp to ?
I guess that your intention was to store commit time in UTC time zone but:
// class org.javers.repository.sql.repositories.CommitMetadataRepository
private Timestamp toTimestamp(LocalDateTime commitMetadata) {
return new Timestamp(commitMetadata.toDate(TimeZone.getTimeZone("UTC")));
}
gives the time which would be in defult time zone (local) if passed (commitMetadata) time will be set in UTC time zone.
F.e. in Europe/Belgrade local time 18:00 is converted to 'UTC' 19:00 but should be to: 17:00
Proper solution should be to create adequate DB colum type (f.e. TIMESTAMP WITH TIME ZONE in Oracle)
and set column value in different way (not resulting to JDBC setTimestamp(idx, ts) as currently is).
JDBC specification suggests using setTimestamp(idx, ts, calendar) - (ts local; calendar in UTC time zone)
but in Oracle it causes saving default time zone instead of UTC (with offsetting the time valid for UTC).
Correct result can be achieved by passing string - date converted to UTC f.e.:
def c = Calendar.getInstance(TimeZone.getTimeZone('UTC'))
def sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z")
sdf.setTimeZone(TimeZone.getTimeZone('UTC'))
def stmt = conc.prepareStatement('INSERT INTO TEST (ts_with_tz) VALUES(?)')
def ts = new Timestamp(new LocalDateTime().toDate().getTime())
stmt.setString(1, sdf.format(ts))
If you want to to store UTC offsetted time in TIMESTAMP column you can use f.e.:
private Timestamp toTimestamp(LocalDateTime commitMetadata) {
return new Timestamp(DateTimeZone.getDefault().convertLocalToUTC(commitMetadata.toDate().getTime(), true))
}
By the way - doing such a change you should warn in release notes that conversion of existing jv_commit.commit_date data is required!
(and provide update scripts)
Cheers
I noticed that 31-12-2015 (13f476b) you changed storing of jv_commit.commit_date from local timestamp to ?
I guess that your intention was to store commit time in UTC time zone but:
gives the time which would be in defult time zone (local) if passed (commitMetadata) time will be set in UTC time zone.
F.e. in Europe/Belgrade local time 18:00 is converted to 'UTC' 19:00 but should be to: 17:00
Proper solution should be to create adequate DB colum type (f.e. TIMESTAMP WITH TIME ZONE in Oracle)
and set column value in different way (not resulting to JDBC setTimestamp(idx, ts) as currently is).
JDBC specification suggests using setTimestamp(idx, ts, calendar) - (ts local; calendar in UTC time zone)
but in Oracle it causes saving default time zone instead of UTC (with offsetting the time valid for UTC).
Correct result can be achieved by passing string - date converted to UTC f.e.:
If you want to to store UTC offsetted time in TIMESTAMP column you can use f.e.:
By the way - doing such a change you should warn in release notes that conversion of existing jv_commit.commit_date data is required!
(and provide update scripts)
Cheers