title: Deserialize Java 8 LocalDateTime with JacksonMapper
body: <p>I have read several questions with answers here in SO concerning serialization and deserialization between <code>java.time.LocalDateTime</code> and JSON property but I can't seem to get it working.</p>
  
  <p>I have managed to configure my Spring Boot Application to return the dates in the format I desire (<code>YYY-MM-dd HH:mm</code>) but I have problems accepting values in this format in JSON.</p>
  
  <p>These are all the things I have done so far:</p>
  
  <p>Added maven dependency for <code>jsr310</code>:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;
      &lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Specified <code>jsr310</code> in my main class:</p>
  
  <pre><code>@EntityScan(basePackageClasses = { App.class, Jsr310JpaConverters.class })
  </code></pre>
  
  <p>Disabled serialization as timestamps in <code>application.properties</code>:</p>
  
  <pre><code>spring.jackson.serialization.write_dates_as_timestamps=false
  </code></pre>
  
  <p>And this is my entity mapping for datetime:</p>
  
  <pre><code>@Column(name = "start_date")
  @DateTimeFormat(iso = DateTimeFormat.ISO.TIME)
  @JsonFormat(pattern = "YYYY-MM-dd HH:mm")
  private LocalDateTime startDate;
  </code></pre>
  
  <p>In my database, I store this date as TIMESTAMP in the following format: <code>2016-12-01T23:00:00+00:00</code>.</p>
  
  <p>If I access this entity via my controller, it returns the JSON with correct startDate format. When I try to post it and deserialize it though, using <code>YYYY-MM-dd HH:mm</code> format, I get the following exception:</p>
  
  <pre><code>{
    "timestamp": "2016-10-30T14:22:25.285+0000",
    "status": 400,
    "error": "Bad Request",
    "exception": "org.springframework.http.converter.HttpMessageNotReadableException",
    "message": "Could not read document: Can not deserialize value of type java.time.LocalDateTime from String \"2017-01-01 20:00\": Text '2017-01-01 20:00' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {MonthOfYear=1, WeekBasedYear[WeekFields[SUNDAY,1]]=2017, DayOfMonth=1},ISO resolved to 20:00 of type java.time.format.Parsed\n at [Source: java.io.PushbackInputStream@679a734d; line: 6, column: 16] (through reference chain: com.gigsterous.api.model.Event[\"startDate\"]); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not deserialize value of type java.time.LocalDateTime from String \"2017-01-01 20:00\": Text '2017-01-01 20:00' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {MonthOfYear=1, WeekBasedYear[WeekFields[SUNDAY,1]]=2017, DayOfMonth=1},ISO resolved to 20:00 of type java.time.format.Parsed\n at [Source: java.io.PushbackInputStream@679a734d; line: 6, column: 16] (through reference chain: com.gigsterous.api.model.Event[\"startDate\"])",
    "path": "/api/events"
  }
  </code></pre>
  
  <p>I know that there are many answers concerning this topic but following them and trying for couple of hours did not help me to figure out what am I doing wrong so I would be glad if someone could point out to me what am I missing. Thanks for any input on this!</p>
  
  <p>EDIT: These are all the classes involved in the process:</p>
  
  <p>Repository:</p>
  
  <pre><code>@Repository
  public interface EventRepository extends PagingAndSortingRepository&lt;Event, Long&gt; {
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity&lt;Event&gt; createEvent(@RequestBody Event event) {
          return new ResponseEntity&lt;&gt;(eventRepo.save(event), HttpStatus.CREATED);
  }
  </code></pre>
  
  <p>My JSON request payalod:</p>
  
  <pre><code>{
    "name": "Test",
    "startDate": "2017-01-01 20:00"
  }
  </code></pre>
  
  <p>Event:</p>
  
  <pre><code>@Entity
  @Table(name = "events")
  @Getter
  @Setter
  public class Event {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "event_id")
      private long id;
  
      @Column(name = "name")
      private String name;
  
      @Column(name = "start_date")
      @DateTimeFormat(iso = DateTimeFormat.ISO.TIME)
      @JsonFormat(pattern = "YYYY-MM-dd HH:mm")
      private LocalDateTime startDate;
  }
  </code></pre>