title: Spring MVC GET @ModelAttribute java.util.Date type with timestamp
body: <p>I have a <code>@RestController</code> that looks something like this:</p>
  
  <pre><code>@RestController
  public class EventSearchController {
  
    @RequestMapping(value = "/api/eventSearch", method = RequestMethod.GET)
    public List&lt;EventDTO&gt; eventSearch(@Valid
                                      @ModelAttribute
                                      EventSearchCommand eventSearchCommand) {
      // ...
    }
  }
  </code></pre>
  
  <p>And my <code>EventSearchCommand</code> looks like this:</p>
  
  <pre><code>@Data
  public class EventSearchCommand {
  
    // other fields that are not a problem here...
  
    private Date startDate;
  
    private Date endDate;
  }
  </code></pre>
  
  <p>The <code>@Data</code> here comes from <a href="https://projectlombok.org/" rel="nofollow">Project Lombok</a>. The issue I'm having is that the startDate and endDate parameters are coming in on the GET string as</p>
  
  <pre><code>?endDate=1453784399000&amp;startDate=1453698000000
  </code></pre>
  
  <p>Are not being bound properly, and I am getting this error:</p>
  
  <blockquote>
    <p>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 1453784399000; nested exception is
    java.lang.IllegalArgumentException: Unable to parse 1453784399000</p>
  </blockquote>
  
  <p>What kind of converter (or more ideally, <code>@DateTimeFormat</code> on the problem fields) do I need to write to get this to bind properly?</p>
  
  <p>I should note that I have another controller set up exactly the same, except the object is annotated <code>@RequestBody</code> instead of <code>@ModelAttribute</code> and the request body is a JSON object where the dates are passed in as integers rather than strings.</p>