Hi,
we have an object with the following fields:
private Date startDateTime; // Time stamp: start of recording in local time zone private Date startDate; // Date: date part of startDateTime private Date startTime; // Time: time part of startDateTime @Basic(optional = false) @Temporal(TemporalType.TIMESTAMP) public Date getStartDateTime() { return startDateTime; } public void setStartDateTime(Date startDateTime) { this.startDateTime = startDateTime; } @Basic(optional = false) @Temporal(TemporalType.DATE) public Date getStartDate() { return startDate; } public void setStartDate(Date startDate) { this.startDate = startDate; } @Basic(optional = false) @Temporal(TemporalType.TIME) public Date getStartTime() { return startTime; } public void setStartTime(Date startTime) { this.startTime = startTime; }
When adding records to the DB close to time when a clock change is expected, for example 2am on the 25/10/2015 Madrid time (when clock goes back 1 hour at 3am), Object DB puts wrong data in the fields annotated with Temporal.DATE.
The attached DB shows the problem and can easily be reproduced.
Here are the values used to set the fields before adding the objects (in the attached DB) to the DB:
Record 1:
startDateTime = Sun Oct 25 02:00:25 CEST 2015
startDate = Sun Oct 25 00:00:00 CEST 2015
startTime = Thu Jan 01 02:00:25 CET 1970
Record 2:
startDateTime = Sun Oct 25 02:00:34 CEST 2015
startDate = Sun Oct 25 00:00:00 CEST 2015
startTime = Thu Jan 01 02:00:34 CET 1970
Record 3:
startDateTime = Sun Oct 25 02:00:44 CEST 2015
startDate = Sun Oct 25 00:00:00 CEST 2015
startTime = Thu Jan 01 02:00:44 CET 1970
Record 4:
startDateTime = Sun Oct 25 02:00:54 CEST 2015
startDate = Sun Oct 25 00:00:00 CEST 2015
startTime = Thu Jan 01 02:00:54 CET 1970
Record 5:
startDateTime = Sun Oct 25 02:01:04 CEST 2015
startDate = Sun Oct 25 00:00:00 CEST 2015
startTime = Thu Jan 01 02:01:04 CET 1970
In the DB you will notice that the startDate field is set to "Sat Oct 24 00:00:00 CEST 2015", i.e. one day before 25th. The other two fields are correct.
This does not happen on other days. For example if add objects with the same time but on the 26th of October, the startDate is set to the 26th.
We would be grateful if you provide an explanation of what is going on.
Thank you
Emil