title: Hibernate/JPA - LocalDate field gets 1 day off when being persisted to a MySQL Date database field
body: <p>Every time a Java LocalDate field is being persisted to a MySQL Date field 1 day is being lost. For instance a Java value of 01 July 2019 would be saved as 30 June 2019 in the Date MySQL column.
  The MySQL database server is configured to have the 'system time zone' as CDT and I don't have permissions to change this.</p>
  
  <p>The Java program is executed from Europe with the following persistence.xml configuration.</p>
  
  <pre><code>&lt;property name="javax.persistence.jdbc.driver"
              value="com.mysql.cj.jdbc.Driver" /&gt;
  
  &lt;property name="javax.persistence.jdbc.url"
              value="...?useTimezone=true&amp;amp;useLegacyDatetimeCode=false&amp;amp;serverTimezone=America/Chicago&amp;amp;autoReconnect=true" /&gt;
  
  &lt;property name="hibernate.dialect"
              value="org.hibernate.dialect.MySQLInnoDBDialect" /&gt;
  
  &lt;property name="hibernate.jdbc.time_zone" value="America/Chicago"/&gt;
  </code></pre>
  
  <p>The value America/Chicago was chosen because the database server is located in that region (MySQL is configured with the CDT time zone but the CDT abbreviation is not valid in Java)</p>
  
  <p>I have tried without the useTimezone=true&amp;useLegacyDatetimeCode=false and there was no difference. I have tried also with simultaneously having serverTimezone=UTC and hibernate.jdbc.time_zone as UTC and without luck also.</p>
  
  <p>In pom.xml I'm using the following jdbc and hibernate versions.</p>
  
  <pre><code>&lt;mysql-connector.version&gt;8.0.18&lt;/mysql-connector.version&gt;
  &lt;hibernate.version&gt;5.4.6.Final&lt;/hibernate.version&gt;
  </code></pre>
  
  <p>Using hibernate version 5.4.6 I understand that JPA 2.2 is supported which means that the LocalDate should be supported out of the box without any converter.</p>
  
  <p>I'm not able to get it working. All the things tried were after reading similar issues on StackOverflow. Whatever I try the date will always come -1 day in the database.</p>
  
  <p>Here you can see all the details<a href="https://i.stack.imgur.com/Q1QXN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q1QXN.png" alt="enter image description here"></a></p>