title: Deserialize LocalDateTime from String with Jackson
body: <p>I'm trying to deserialize a <code>String</code> to <code>LocalDateTime</code> with Jackson but it doesn't work.</p>
  
  <p>I have a data class with a LocalDateTime field:</p>
  
  <pre><code>@Data
  public class Registration {
      @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd hh:mm:ss")
      private LocalDateTime timestamp;
  }
  </code></pre>
  
  <p>I added the special Jackson datatype modules:</p>
  
  <pre><code>compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
  </code></pre>
  
  <p>The serialization works fine with:</p>
  
  <pre><code>new ObjectMapper().registerModule(new JavaTimeModule()).writeValueAsString(registration);
  </code></pre>
  
  <p>Result String:</p>
  
  <pre><code>{"timestamp":"2018-09-03 10:09:35"}
  </code></pre>
  
  <p>But the deserialization doesn't work with:</p>
  
  <pre><code>new ObjectMapper().registerModule(new JavaTimeModule()).readValue(json.traverse(), Registration.class)
  </code></pre>
  
  <p>As error I get:</p>
  
  <pre><code>Cannot deserialize value of type `java.time.LocalDateTime` from String "2018-09-03 10:09:35": 
      Failed to deserialize java.time.LocalDateTime: 
          (java.time.format.DateTimeParseException) Text '2018-09-03 10:09:35' could not be parsed: 
              Unable to obtain LocalDateTime from TemporalAccessor: 
                  {MinuteOfHour=9, NanoOfSecond=0, SecondOfMinute=35, MicroOfSecond=0, MilliOfSecond=0, HourOfAmPm=10},
                  ISO resolved to 2018-09-03 of type java.time.format.Parsed
  </code></pre>
  
  <p>What am I missing? I'm confused that the serialization works but the deserialization doesn't.</p>
  
  <hr>
  
  <p><strong>MWE:</strong> (small gradle Java project)</p>
  
  <p>Main.java:</p>
  
  <pre><code>import java.io.IOException;
  import java.time.LocalDateTime;
  
  import com.fasterxml.jackson.annotation.JsonFormat;
  import com.fasterxml.jackson.core.TreeNode;
  import com.fasterxml.jackson.databind.ObjectMapper;
  import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
  
  public class Main {
  
      public static void main(String[] args) throws IOException {
          Registration registration = new Registration();
          registration.setTimestamp(LocalDateTime.now());
  
           ObjectMapper objectMapper = new ObjectMapper().registerModule(new JavaTimeModule());
  
           String s = objectMapper.writeValueAsString(registration);
           TreeNode treeNode = objectMapper.readTree(s);
  
           //Fails here:
           Registration registration1 = objectMapper.readValue(treeNode.traverse(), Registration.class);
  
          System.out.println(registration1);
      }
  }
  
  class Registration {
      @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd hh:mm:ss")
      private LocalDateTime timestamp;
  
      public Registration() {
      }
  
      public LocalDateTime getTimestamp() {
          return this.timestamp;
      }
  
      public void setTimestamp(LocalDateTime localDateTime) {
          this.timestamp = localDateTime;
      }
  }
  </code></pre>
  
  <p>build.gradle:</p>
  
  <pre><code>plugins {
      id 'java'
  }
  
  group 'dateMWE'
  version '1.0-SNAPSHOT'
  
  sourceCompatibility = 10
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile("com.fasterxml.jackson.core:jackson-annotations:2.9.6")
      compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.6")
  }
  </code></pre>