title: Converting String into LocalDateTime using Java 8 DateTimeFormatter
body: <p>I'm using Java 8 and I have a string in my <code>.txt</code> file which I want to convert into a <code>LocalDateTime</code> object.</p>
  
  <pre><code>String time1 = "2017-10-06T17:48:23.558";
  
  DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("dd.MM.yyyy. HH:mm:ss");
  LocalDateTime alarmTime = LocalDateTime.parse(time1, formatter1);
  
  System.out.println(time1);
  </code></pre>
  
  <p>This gives me this exception:</p>
  
  <pre><code>Exception in thread "main" java.time.format.DateTimeParseException: Text '2017-10-06T17:48:23.558' could not be parsed at index 2
  at java.time.format.DateTimeFormatter.parseResolved0(Unknown Source)
  at java.time.format.DateTimeFormatter.parse(Unknown Source)
  at java.time.LocalDateTime.parse(Unknown Source)
  </code></pre>
  
  <p>Any ideas? </p>
  
  <p>P.S. Note that this:</p>
  
  <pre><code>DateTimeFormatter formatter = DateTimeFormat.forPattern("dd.MM.yyyy. HH:mm:ss");
  DateTime dt = formatter.parseDateTime(string);
  </code></pre>
  
  <p>doesn't work in Java 8.</p>
  
  <p>Edit: I didn't make the question clear enough, my bad:</p>
  
  <p>I have this string in my <code>.txt</code> file, and I need to convert it to <code>LocalDateTime</code> object in order to save it into a class object, but I need it in the format stated in order to print it out inside a table. I don't want it to print out in the raw format that is <code>"2017-10-06T17:48:23.558"</code>. I want it to print out something like this: <code>"10.06.2017. 17:48:23"</code></p>