title: java.time.DateTimeFormatter : Need ISO_INSTANT that always renders milliseconds
body: <p>I'm trying to cleanup a mix of various code around datetime management to only Java 8 <a href="http://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html" rel="noreferrer"><code>java.time</code></a> namespace. Right now I have a small issue with the default <a href="https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html" rel="noreferrer"><code>DateTimeFormatter</code></a> for <a href="https://docs.oracle.com/javase/8/docs/api/java/time/Instant.html" rel="noreferrer"><code>Instant</code></a>. The <a href="https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_INSTANT" rel="noreferrer"><code>DateTimeFormatter.ISO_INSTANT</code></a> formatter only shows milliseconds when they are not equal to zero.</p>
  
  <p>The epoch is rendered as <code>1970-01-01T00:00:00Z</code> instead of <code>1970-01-01T00:00:00.000Z</code>.</p>
  
  <p>I made a unit test to explain the problem and how we need to final dates to be compared one to each other.</p>
  
  <pre><code>@Test
  public void java8Date() {
      DateTimeFormatter formatter = DateTimeFormatter.ISO_INSTANT;
      String epoch, almostEpoch, afterEpoch;
  
      { // before epoch
          java.time.Instant instant = java.time.Instant.ofEpochMilli(-1);
          almostEpoch = formatter.format(instant);
          assertEquals("1969-12-31T23:59:59.999Z", almostEpoch );
      }
  
      { // epoch
          java.time.Instant instant = java.time.Instant.ofEpochMilli(0);
          epoch = formatter.format(instant);
          // This fails, I get 1970-01-01T00:00:00Z instead
          assertEquals("1970-01-01T00:00:00.000Z", epoch );
      }
  
      { // after epoch
          java.time.Instant instant = java.time.Instant.ofEpochMilli(1);
          afterEpoch = formatter.format(instant);
          assertEquals("1970-01-01T00:00:00.001Z", afterEpoch );
      }
  
      // The end game is to make sure this rule is respected (this is how we order things in dynamo):
      assertTrue(epoch.compareTo(almostEpoch) &gt; 0);
      assertTrue(afterEpoch.compareTo(epoch) &gt; 0); // &lt;-- This assert would also fail if the second assert fails
  
      { // to confirm we're not showing nanos
          assertEquals("1970-01-01T00:00:00.000Z", formatter.format(Instant.EPOCH.plusNanos(1)));
          assertEquals("1970-01-01T00:00:00.001Z", formatter.format(Instant.EPOCH.plusNanos(1000000)));
      }
  }
  </code></pre>