title: How do I deserialize 24 hour date string to LocalDate using Jackson and RestTemplate
body: <p>I have the following...</p>
  
  <pre><code>public static final String DATE_PATTERN = "yyyy-MM-dd'T'hh:mm:ss.SSSZ";
  @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_PATTERN)
  private LocalDate created;
  
  return this.restTemplate.postForObject(url, entity, SearchResult.class);
  </code></pre>
  
  <p>When I run the code it errors out with the following...</p>
  
  <pre><code>java.time.DateTimeException: Invalid value for ClockHourOfAmPm (valid values 1 - 12): 13
      at java.base/java.time.temporal.ValueRange.checkValidValue(ValueRange.java:311) ~[na:na]
      at java.base/java.time.temporal.ChronoField.checkValidValue(ChronoField.java:717) ~[na:na]
  </code></pre>
  
  <p>How do I deserialize this to a LocalDate? Regular Java7 date works fine.</p>
  
  <p><strong>The Final Solution Looks like this</strong></p>
  
  <pre><code>public static final String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
  
  public class LocalDateDeserializer extends StdDeserializer&lt;LocalDate&gt;{
      protected LocalDateDeserializer(){
          super(LocalDate.class);
      }
      @Override
      public LocalDate deserialize(JsonParser parser, DeserializationContext context) throws IOException {
          return LocalDate.parse(parser.readValueAs(String.class), DateTimeFormatter.ofPattern(JiraService.DATE_PATTERN));
      }
  }
  
  public class LocalDateSerializer extends StdSerializer&lt;LocalDate&gt; {
  
      public LocalDateSerializer() {
          super(LocalDate.class);
      }
  
      @Override
      public void serialize(LocalDate value, JsonGenerator generator, SerializerProvider provider) throws IOException {
          generator.writeString(value.format(DateTimeFormatter.ofPattern(JiraService.DATE_PATTERN)));
      }
  }
  
  @JsonDeserialize(using = LocalDateDeserializer.class)
  @JsonSerialize(using = LocalDateSerializer.class)
  private LocalDate created;
  </code></pre>