title: How to store a Java Instant in a MySQL database
body: <p>With Java <code>Date</code> objects the easiest way to go was to store them as MySql <code>DateTime</code> objects (in UTC). With the switch to <code>Instant</code> this approach won't work anymore because MySQL <code>DateTime</code> does not offer the precision to store nanoseconds. Just truncating them could lead to unexpected comparison results between a newly created <code>Instant</code> objects and the ones read from the database.</p>
  
  <p><code>BigDecimal</code> timestamps don't strike me as an elegant solution: writing select queries manually becomes more difficult because you have to convert the timestamp everywhere to make it readable, and the handling in Java is somewhat clunky compared to <code>Instant</code> or even <code>Long</code> values.</p>
  
  <p>What's the best way to go here? Probably not <code>varchar</code>, right?</p>