I've noticed that my MySql database is subtracting an hour from my DateTime objects when I insert certain dates to my tables. Example:
Insert: 2021-03-29 11:44:14.938
Result: 2021-03-29 10:44:14.938
I am inserting Java.Sql.Timestamp object (timestamp
below) using JdbcTemplate.update:
jdbcTemplate.update(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
PreparedStatement stmt = con.prepareStatement(
"INSERT INTO Table (date) VALUES (?)");
stmt.setTimestamp(5,timestamp));
return stmt;
}
});
This is only happening for DateTime on/after 28th March 2021 (which is daylight saving time here in the UK). If I insert before 28th March, no time is lost. Example:
Insert: 2021-03-26 11:44:14.938
Result: 2021-03-26 11:44:14.938
I have tried using Timestamp rather than DateTime as the MySQL type but it has no effect.
Does anyone know how to stop this behaviour?