title: Java 8 ZonedDateTime or OffsetDateTime to replace Joda DateTime
body: <p>Before Java8, I used Joda's <code>DateTime</code> class to include timezone information and I can easily to convert between <code>DateTime</code> and sql <code>Timestamp</code>.</p>
  
  <p>Once migrate to Java8, which class I should replace? <code>OffsetDateTime</code> or <code>ZonedDateTime</code>?</p>
  
  <p>Also, I tried to use <code>OffsetDateTime</code>, but it seems can't construct back to <code>OffsetDateTime</code> from a sql <code>Timestamp</code>.</p>
  
  <p>For Joda <code>DateTime</code> and <code>Timestamp</code> converter, the code is like:</p>
  
  <pre><code>val joda = DateTime.now()
  val sqlJoda = new Timestamp(joda.getMillis)
  val jodaBack = new DateTime(sqlJoda)
  </code></pre>
  
  <p>But for Java8,</p>
  
  <pre><code>val java8 = OffsetDateTime.now()
  val sqlJava8 = new Timestamp(java8.toInstant.toEpochMilli)
  val java8Back = ???
  </code></pre>
  
  <p>Anyone has some idea about that? It seems Joda <code>DateTime</code> is really good.</p>