title: Forcing Java 8 LocalTime toString to report omitted values
body: <p>I have the following datetime helper method that converts a UTC-zoned Java 8 <code>Date</code> into a datetime string:</p>
  
  <pre><code>public static String dateTimeString(Date date) {
      return date.toInstant().atZone(ZoneId.of("UTC")).toLocalDateTime().toString();
  }
  </code></pre>
  
  <p>The desired result is to <em>always</em> have the resultant String be formatted as:</p>
  
  <blockquote>
    <p>YYYY-MM-dd'T'HH:mm:ss'Z'</p>
  </blockquote>
  
  <p>Problem is, Java 8 <code>LocalTime#toString()</code> <strong>intentionally</strong> strips off time components that are zero. So for instance if I have a <code>Date</code> instance that represents <strong>June 8, 2018 at 12:35:00 UTC</strong>. Then the output of this method above is: <em>2018-06-08'T'12:35'Z'</em>. Whereas I want it to contain any zeroed-out second/minute/hour components (e.g. <em>2018-06-08'T'12:35:00'Z'</em>).</p>
  
  <p><strong>Any ideas?</strong></p>