title: Failed to convert string in java.util.Date with @DateTimeFormat(pattern="dd/MM/yyyy")
body: <p>I have a simple <code>POJO</code> with a Date field. I want to bind the object with values from a form.<br>
  In the form I'm using <code>jquery ui datepicker</code> with date format("dd/mm/yyyy")<br>
  I have <code>console.log</code> the value and is a string : 13-11-2014<br>
  I'm using <code>spring 4.0.7</code><br>
  I have on my dependencies joda-time 2.5</p>
  
  <p><strong>I get this exception:</strong> </p>
  
  <pre><code>Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'endDate'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @org.springframework.format.annotation.DateTimeFormat java.util.Date for value '22-11-2014'; nested exception is java.lang.IllegalArgumentException: Invalid format: "22-11-2014" is malformed at "-11-2014"]
  </code></pre>
  
  <p><strong>My POJO:</strong></p>
  
  <pre><code>    package gr.gsis.announcement.model;
  
  
      import java.io.Serializable;
      import java.util.Date;
  
      import org.springframework.format.annotation.DateTimeFormat;
  
      public class Announcement implements Serializable{
  
          private static final long serialVersionUID = -1984554807132781312L;
  
          private int id;
          private String title;
          private String bodyText;
  
          @DateTimeFormat(pattern = "dd/MM/yyyy")
          private Date startDate;
  
          @DateTimeFormat(pattern = "dd/MM/yyyy")
          private Date endDate;
  
          private boolean activeFlag;
  
          public Announcement() {
  
          }
  
          public Announcement(int id, String title, Date startDate, Date endDate,
                  boolean activeFlag) {
              this.id = id;
              this.title = title;
              this.startDate = startDate;
              this.endDate = endDate;
              this.activeFlag = activeFlag;
          }
  
  
          public int getId() {
              return id;
          }
  
          public void setId(int id) {
              this.id = id;
          }
  
          public String getTitle() {
              return title;
          }
  
          public void setTitle(String title) {
              this.title = title;
          }
  
          public String getBodyText() {
              return bodyText;
          }
  
          public void setBodyText(String bodyText) {
              this.bodyText = bodyText;
          }
  
          public Date getStartDate() {
              return startDate;
          }
  
          public void setStartDate(Date startDate) {
              this.startDate = startDate;
          }
  
          public Date getEndDate() {
              return endDate;
          }
  
          public void setEndDate(Date endDate) {
              this.endDate = endDate;
          }
  
          public boolean getActiveFlag() {
              return activeFlag;
          }
  
          public void setActiveFlag(boolean activeFlag) {
              this.activeFlag = activeFlag;
          }
  
          @Override
          public String toString() {
              return "Announcement [id=" + id + ", title=" + title + ", bodyText="
                      + bodyText + ", startDate=" + startDate + ", endDate="
                      + endDate + ", activeFlag=" + activeFlag + "]";
          }
  </code></pre>
  
  <p><strong>My controller:</strong></p>
  
  <pre><code>    package gr.gsis.announcement.controller;
  
      import gr.gsis.announcement.model.Announcement;
  
      import org.springframework.stereotype.Controller;
      import org.springframework.ui.Model;
      import org.springframework.web.bind.annotation.ModelAttribute;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RequestMethod;
  
      @Controller
      public class AnnouncementController {
  
          @RequestMapping("/")
          public String welcome(Model model) {
              model.addAttribute("greeting", "Welcome");
  
              return "welcome";
  
          }
  
          @RequestMapping(value="/create", method = RequestMethod.GET)
          public String getAnnouncementForm(Model model) {
  
              Announcement announcement = new Announcement();
  
              model.addAttribute("announcement", announcement);
  
              return "announcementForm";
          }
  
          @RequestMapping(value = "/create", method = RequestMethod.POST)
          public String processAnnouncement(@ModelAttribute("announcement") Announcement announcement) {
  
              System.out.println(announcement);
  
              return "announcementForm";
          }
      }
  </code></pre>
  
  <p><strong>my Form JSP:</strong></p>
  
  <pre><code>    &lt;h2&gt;Insert Announcement&lt;/h2&gt;
  
          &lt;form:form method="post" commandName="announcement"&gt;
  
              &lt;div&gt;
                  &lt;form:label path="title"&gt;Title&lt;/form:label&gt;
                  &lt;form:input path="title" name="title" type="text"/&gt;
              &lt;/div&gt;
  
              &lt;div&gt;
                  &lt;form:label path="startDate"&gt;Start Date&lt;/form:label&gt;
                  &lt;form:input path="startDate" cssClass="datepicker start"  name="startDate" type="text"/&gt;
              &lt;/div&gt;
  
              &lt;div&gt;
                  &lt;form:label path="endDate"&gt;End Date&lt;/form:label&gt;
                  &lt;form:input path="endDate" cssClass="datepicker end" name="endDate" type="text"/&gt;
              &lt;/div&gt;
  
              &lt;div&gt;
                  &lt;form:label path="activeFlag"&gt;Active&lt;/form:label&gt;
                  &lt;form:checkbox path="activeFlag" name="activeFlag"/&gt;
              &lt;/div&gt;
  
  
              &lt;div&gt;
                  &lt;input type="submit" class="button" value="Save" /&gt;
              &lt;/div&gt;
  
          &lt;/form:form&gt;
      &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          $(function() {
              $( ".datepicker" ).datepicker({ dateFormat: 'dd-mm-yy' });
  
  
          });
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks in advance</p>