title: Get Date from JSP to Controller (in Spring Mvc)
body: <p>I woulde like to get <strong>Date from my JSP to my Controller</strong> but I tried all but I still not get a result:</p>
  
  <p><strong>JSP</strong></p>
  
  <pre><code>&lt;div&gt;
      &lt;f:form modelAttribute="banqueForm2" method="post"  action="testero33"&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;Date1 :&lt;/td&gt;
                  &lt;td&gt;&lt;f:input path="date1" type="date" name="date" /&gt; 
                  &lt;/td&gt;
                  &lt;td&gt;&lt;f:errors path="date1" cssClass="error"&gt;
                      &lt;/f:errors&gt;&lt;/td&gt;
  
                      &lt;td&gt;Date2 :&lt;/td&gt;
                  &lt;td&gt;&lt;f:input path="date2" type="date"  name="date" /&gt; 
                  &lt;/td&gt;
                  &lt;td&gt;&lt;f:errors path="date2" cssClass="error"&gt;
                      &lt;/f:errors&gt;&lt;/td&gt;
  
                  &lt;td&gt;&lt;input type="submit" value="OK" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/f:form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>@RequestMapping(value="/testero33")
  public String testero3(@Valid BanqueForm2  bf, Model model, Date date1, Date date2){ 
      System.out.println("-------------date JSP---------------:  ");
      System.out.println("*** Cosluter Strin ***:  " + date1);
      System.out.println("*** Cosluter Strin ***:  " + date2);
  
      System.out.println("------------End JSP---------------:  ");
  
      return "DateTest";
  }
  </code></pre>
  
  <p><strong>BanqueForm2.class</strong></p>
  
  <pre><code>public class BanqueForm2 {
  
      private Date date1;
      private Date date2;
  
  
      public Date getDate1() {
          return date1;
      }
      public void setDate1(Date date1) {
          this.date1 = date1;
      }
      public Date getDate2() {
          return date2;
      }
      public void setDate2(Date date2) {
          this.date2 = date2;
      }
  }
  </code></pre>
  
  <p>Then I get this exception</p>
  
  <pre><code>Field error in object 'banqueForm2' on field 'date1': rejected value [2015-10-01]; codes [typeMismatch.banqueForm2.date1,typeMismatch.date1,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [banqueForm2.date1,date1]; arguments []; default message [date1]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'date1'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.util.Date for value '2015-10-01'; nested exception is java.lang.IllegalArgumentException]
  Field error in object 'banqueForm2' on field 'date2': rejected value [2015-02-12]; codes [typeMismatch.banqueForm2.date2,typeMismatch.date2,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [banqueForm2.date2,date2]; arguments []; default message [date2]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'date2'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.util.Date for value '2015-02-12'; nested exception is java.lang.IllegalArgumentException]org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:111)
  </code></pre>