title: Date type with Thymeleaf
body: <p>Working with Thymeleaf i get this error in a form POST method at my html template:</p>
  <pre><code>There was an unexpected error (type=Bad Request, status=400).
  Validation failed for object='miembro'. Error count: 2
  org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 2 errors
  Field error in object 'miembro' on field 'fechaIngreso': rejected value [2020-10-12]; codes [typeMismatch.miembro.fechaIngreso,typeMismatch.fechaIngreso,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [miembro.fechaIngreso,fechaIngreso]; arguments []; default message [fechaIngreso]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'fechaIngreso'; nested exception is java.lang.IllegalArgumentException: Could not parse date: Unparseable date: &quot;2020-10-12&quot;]
  Field error in object 'miembro' on field 'fechaNacimiento': rejected value [1992-11-12]; codes [typeMismatch.miembro.fechaNacimiento,typeMismatch.fechaNacimiento,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [miembro.fechaNacimiento,fechaNacimiento]; arguments []; default message [fechaNacimiento]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'fechaNacimiento'; nested exception is java.lang.IllegalArgumentException: Could not parse date: Unparseable date: &quot;1992-11-12&quot;]
  </code></pre>
  <p>Seems it's a problem with date parsing. The rejected values are in yyyy-MM-dd, but i alreay inserted anotations in that format in every Date attribute inside the project. example:</p>
  <pre><code>@Entity
  public class Miembro extends Persona {
      
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private int idMiembro;
      @DateTimeFormat(pattern = &quot;yyyy-MM-dd&quot;)
      @Temporal(TemporalType.DATE)
      private Date fechaIngreso;
  </code></pre>
  <p>also, the SQL column types are correctly mapped as &quot;date&quot; type.</p>
  <p>The problematic Thymeleaf portion of code:</p>
  <pre><code>&lt;div class=&quot;jumbotron&quot; th:if=&quot;${habilitarIngreso}&quot;&gt;
    &lt;form th:action=&quot;principal&quot; th:object=&quot;${miembroP}&quot; method=&quot;post&quot;&gt;
      &lt;label&gt;Nombre&lt;/label&gt;
      &lt;input type=&quot;text&quot; th:field=&quot;*{nombre}&quot; 
      placeholder=&quot;Ingrese nombre&quot;/&gt;
       &lt;label&gt;Apellido&lt;/label&gt;
       &lt;input type=&quot;text&quot; th:field=&quot;*{apellido}&quot; 
      placeholder=&quot;Ingrese apellido&quot;/&gt;
        &lt;label&gt;D.N.I&lt;/label&gt;
       &lt;input type=&quot;number&quot; th:field=&quot;*{dni}&quot; 
      placeholder=&quot;Ingrese dni&quot;/&gt;
            &lt;label&gt;Teléfono&lt;/label&gt;
       &lt;input type=&quot;number&quot; th:field=&quot;*{telefono}&quot; 
      placeholder=&quot;Ingrese teléfono&quot;/&gt;
      &lt;label&gt;Dirección&lt;/label&gt;
      &lt;input type=&quot;text&quot; th:field=&quot;*{direccion}&quot; 
     placeholder=&quot;Ingrese dirección&quot;/&gt;  
     &lt;label&gt;Fecha Nacimiento&lt;/label&gt;
       &lt;input type=&quot;date&quot; th:field=&quot;*{fechaNacimiento}&quot; 
      placeholder=&quot;Ingrese fecha de nacimiento&quot;/&gt;   
      &lt;label&gt;Fecha de ingreso&lt;/label&gt;
       &lt;input type=&quot;date&quot; th:field=&quot;*{fechaIngreso}&quot; 
      placeholder=&quot;Ingrese fecha de ingreso&quot;/&gt;
        &lt;input type=&quot;submit&quot; value=&quot;Enviar&quot;/&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  <p>can you please give me a hint on what's happening?</p>