title: How to convert the MongoDB object id to a Java Date or Instant using Java
body: <p>The MongoDB ObjectID contains an embedded timestamp of its creation time. How can you extract this timestamp with plain Java without using classes of a driver library?</p>
  
  <p>MongoDB creates object id's that typically look like:</p>
  
  <pre><code>5b86bd41840a1be5a55c7022
  598af6efe4b09fc2332cf16a
  598ad932e4b0f0f169b42d5f
  </code></pre>
  
  <p>The extraction target can be either a <code>long</code>, <code>java.util.Date</code> or a <code>java.time.Instant</code>.</p>