title: Spring change date input format
body: <p>I am trying to create a form, that will send back an object with a timestamp. Right now, the input format must be <code>yyyy-MM-dd HH:mm:ss</code>, I want the timestamp to be entered in the format <code>dd.MM.yyyy HH:mm</code> - how can I change the input format?</p>
  
  <p>The object class:</p>
  
  <pre><code>public class Test {
      private Timestamp dateStart;
  
      public Timestamp getDateStart() {
          return dateStart;
      }
      public void setDateStart(Timestamp dateStart) {
          this.dateStart = new Timestamp(dateStart.getTime());
      }
  }
  </code></pre>
  
  <p>The controller method:</p>
  
  <pre><code>@RequestMapping(value="test", method = RequestMethod.POST)
  public View newTest(@ModelAttribute("test") Test test, Model model) {
      //save the Test object
  }
  </code></pre>
  
  <p>The jsp form:</p>
  
  <pre><code>&lt;form:form action="service/test" method="post" modelAttribute="test"&gt;
      &lt;form:input type="text" path="dateStart" /&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>I get this error, when the format isn't right:</p>
  
  <pre><code>Field error in object 'test' on field 'dateStart': rejected value [22.05.2012 14:00]; codes [typeMismatch.test.dateStart,typeMismatch.dateStart,typeMismatch.java.sql.Timestamp,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [test.dateStart,dateStart]; arguments []; default message [dateStart]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.sql.Timestamp' for property 'dateStart'; nested exception is org.springframework.core.convert.ConversionFailedException: Unable to convert value "22.05.2012 14:00" from type 'java.lang.String' to type 'java.sql.Timestamp'; nested exception is java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]]
  </code></pre>