I have a java ZonedDateTime which I am trying to insert into a MySQL Date column (the DBA refuses to change the type – the date should have a time component since it is an audit date/time for when an event occurs – I would like to have the java code retain the time in case someday the DBA changes their mind).
When MyBatis tries to insert the ZonedDateTime into the Date column, I receive the following error:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect date value: 'xACxEDx00x05srx00x0Djava.time.Serx95]x84xBAx1B''HxB2x)Cx00....' for column auditDate at row 1
What would be the best way to get MyBatis to insert the ZonedDateTime into the MySQL Date column? Do I need to cast to a java.util.Date or some other type to successfully perform the insertion?
Some User is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.