title: Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalDate' for property 'date' in thymeleaf form
body: <pre><code>&lt;form th:action="@{/hi}"  th:object="${datum}" method="post"&gt;
      &lt;p&gt;date : &lt;input type="date" th:field="*{date}"/&gt; &lt;/p&gt;
      &lt;p&gt;&lt;input type="submit" value="Submit" /&gt; &lt;input type="reset" value="Reset" /&gt;&lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Controller for form above</p>
  
  <pre><code>@PostMapping("/hi")
  fun testum(@ModelAttribute datum: Datum) {
      println(datum)
  }
  </code></pre>
  
  <p>simple pojo class</p>
  
  <pre><code>class Datum(
          @DateTimeFormat(pattern = "yyyy-MM-dd")
          var date: LocalDate? = null
  )
  </code></pre>
  
  <p>I am trying to send date in form but get this exception:</p>
  
  <pre><code>Resolved exception caused by Handler execution: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
  Field error in object 'datum' on field 'date': rejected value [2018-06-20]; codes [typeMismatch.datum.date,typeMismatch.date,typeMismatch.java.time.LocalDate,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [datum.date,date]; arguments []; default message [date]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalDate' for property 'date'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.time.LocalDate] for value '2018-06-20'; nested exception is java.lang.IllegalArgumentException: Parse attempt failed for value [2018-06-20]]
  </code></pre>
  
  <p>But if I change type from LocalDate to String it works fine. I want to map date that is in form to date property of Datum class. can anyone help me with that? any links? thanks.</p>
  
  <p>This link did not help me <a href="https://stackoverflow.com/questions/43079923/localdate-in-form">similar problem</a></p>