title: Convert String to LocalDateTime Java 8
body: <p>I'm trying to convert the following String into a LocalDateTime:</p>
  <pre><code>String dateStr = &quot;2020-08-17T10:11:16.908732&quot;; 
  
  DateTimeFormatter format = DateTimeFormatter.ofPattern(&quot;yyyy-MM-dd HH:mm:ss.nnnnnn&quot;);
  LocalDateTime dateTime = LocalDateTime.parse(dateStr, format);
  </code></pre>
  <p>But I'm hitting the following error:</p>
  <pre><code>java.time.format.DateTimeParseException: Text '2020-08-17T10:11:16.908732' could not be parsed at index 10
      at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
      at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)
      at java.time.LocalDateTime.parse(LocalDateTime.java:492)
  </code></pre>
  <p>Can anyone please help to advise how I should be correctly formatting the string into a LocalDateTime?</p>
  <p>Many thanks</p>