title: Copying TIMESTAMP to DATETIME on MySQL with Hibernate
body: <p>I have these two classes</p>
  
  <pre><code>class Source {
      // mapped to TIMESTAMP
      @Version
      @Column(columnDefinition="TIMESTAMP(3) DEFAULT '2016-01-01'")
      Instant myInstant;
  }
  
  class Destination {
      // mapped to DATETIME
      @Basic(optional=true)
      Instant myInstant;
  }
  </code></pre>
  
  <p>When using Hibernate, I assign</p>
  
  <pre><code>destination.myInstant = source.myInstant;
  </code></pre>
  
  <p>and then the stored value is smaller by one hour than the original - both according to the command line MySQL client and in Java. My current timezone is UTC+1, so the reason is obviously a timezone conversion.</p>
  
  <p>There are a few places where this can be fixed, but I'm looking for the best practice. The server should work world-wide, so it should continue to use UTC internally, right?</p>
  
  <p>Should I just change the column type to <code>TIMESTAMP</code>? Then, why does <code>Instant</code> by default map to <code>DATETIME</code>?</p>
  
  <hr>
  
  <p>According to <a href="http://www.thoughts-on-java.org/hibernate-5-date-and-time/" rel="noreferrer">this article</a>, <code>Instant</code> <em>does</em> map to <code>TIMESTAMP</code>, but in my case it did not. Why?</p>