title: Java 8 optional time part not working
body: <p>I am trying to create date time format for optional time part currently I implemented this</p>
  <pre><code>import java.time.*;
  import java.time.format.DateTimeFormatter;
  import java.time.format.DateTimeParseException;
  import java.text.ParseException;
  
  /* Name of the class has to be &quot;Main&quot; only if the class is public. */
  class Ideone
  {
      public static void main (String[] args) throws java.lang.Exception
      {
          System.out.println(Ideone.getDate(&quot;2017-07-01T00:00:00.0Z&quot;));
          System.out.println(Ideone.getDate(&quot;2017-07-01T00:00:00.00Z&quot;));
          System.out.println(Ideone.getDate(&quot;2017-07-01T00:00:00.000Z&quot;));
      }
      
      public static LocalDateTime getDate(String date) {
          try {
             
              DateTimeFormatter formatter2 =
                  DateTimeFormatter.ofPattern(&quot;yyyy-MM-dd'T'HH:mm:ss[.SSS]'Z'&quot;);
              LocalDateTime ldt = LocalDateTime.parse(date, formatter2);
              
              
              return ldt;
             
          } catch (DateTimeParseException ex) {
              return null;
          }
      }
  }
  </code></pre>
  <p>And having output</p>
  <blockquote>
  <p>null</p>
  <p>2017-07-01T00:00</p>
  <p>2017-07-01T00:00</p>
  </blockquote>
  <p>Now my question is, why date with 1 time fraction is not working and it is working with 2 and 3 fractions? should it entertain 1,2 and 3 fractions? or only 3 fractions?</p>
  <p>Thanks in advance</p>