title: How to make Spring Data Elasticsearch work with java.time.LocalDateTime for date
body: <p>I am using Spring Data support for Elasticsearch. Here is the timestamp field mapping:</p>
  
  <pre><code>@Field(type = FieldType.Date, index = FieldIndex.not_analyzed, store = true,
          format = DateFormat.custom, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZZ")
  @JsonFormat(shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd'T'HH:mm:ss.SSSZZ")
  private LocalDateTime timestamp;
  </code></pre>
  
  <p>This results in mapping of the field in Elasticsearch as follows:</p>
  
  <pre><code>"timestamp":{"type":"date","store":true,"format":"yyyy-MM-dd'T'HH:mm:ss.SSSZZ"}
  </code></pre>
  
  <p>When I use java.util.Date instead everything works fine. However, when I switch to java.time.LocalDateTime as above the document sent to Elasticsearch causes an exception. Here is the document (timestamp field only for brevity):</p>
  
  <pre><code>"timestamp": {
      "hour":7, "minute":56, "second":9, "nano":147000000, "year":2017, "month":"FEBRUARY",
      "dayOfMonth":13, "dayOfWeek":"MONDAY", "dayOfYear":44, "monthValue":2, "chronology": {
          "id":"ISO", "calendarType": "iso8601"
      }
  }
  </code></pre>
  
  <p>And the exception:</p>
  
  <pre><code>MapperParsingException[failed to parse [timestamp]]; nested: IllegalArgumentException[unknown property [hour]];
  (...)
  Caused by: java.lang.IllegalArgumentException: unknown property [hour]
  </code></pre>
  
  <p>It looks like the pattern is being ignored here when jsonizing the document. Any possible tips? Or perhaps you might know how to use the "built-in" _timestamp field with Spring Data?</p>