JadiraOrg/jadira

Incompatible handling of timezones in 7.0.0.CR1

Opened this issue · 1 comments

Upgrading from Version 6.0.1.GA to 7.0.0.RC1 we encountered the following issue:

We use the following JPA Mapping to persist a Joda Datetime field.

    @Columns(columns = {
            @Column(name = "valid_until"),
            @Column(name = "valid_until_timezone")
    })
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTimeAndZoneWithOffset")
    protected DateTime validUntil;

In all versions before 7.0.0.RC1 the Date "2018-11-05T23:59:59+01:00" would result in the following DB Entries.

valid_until valid_until_timezone
2018-11-05 22:59:59 Europe/Berlin{+01:00}

Time is saved in UTC, Timezone information is written to the second field.
After reading the record from DB, the timezone gets reapplied and the Joda DateTime Object in Memory is set to "23:59:59".

After upgrading to 7.0.0.RC1 the same date gets persisted like this:

valid_until valid_until_timezone
2018-11-05 23:59:59 Europe/Berlin{+01:00}

The time is not saved in UTC anymore and is written as is. When reading from DB the Joda DateTime Object in Memory is set correctly to "23:59:59".

This works fine for all new records inserted by the new version of Jadira, but all old records are off by one hour (or better the zone offset).

Is this breaking change intended or did it happen by mistake?

regards

Thomas

This worked prior to this change:
b5c6629

Now jadira is incapable of converting dates during the repeated 1am hour during the daylight time changeover.

Looks like the problem for me is in TimestampColumnDateTimeMapper:
The change from
DateTime dateTime = new DateTime(value.getTime());
to:
DateTime dateTime = DATETIME_FORMATTER.parseDateTime(value.toString());
makes it completely mess up dates in the daylight saving time repeated 1am hour. Converting it first to a string loses timezone information.