spring-cloud-feign Client and @RequestParam with Date type
<p>This time I was working with Declarative REST Client, Feign in some Spring Boot App.</p>

<p>What I wanted to achieve is to call one of my REST API's, which looks like: </p>

<pre><code>@RequestMapping(value = "/customerslastvisit", method = RequestMethod.GET)
    public ResponseEntity customersLastVisit(
            @RequestParam(value = "from", required = true) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date from,
            @RequestParam(value = "to", required = true) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date to) {
</code></pre>

<p>As You can see, the API accepts calls with from and to Date params formatted like <code>(yyyy-MM-dd)</code> </p>

<p>In order to call that API, I've prepared following piece of <code>@FeignClient</code>:</p>

<pre><code>@FeignClient("MIIA-A")
public interface InboundACustomersClient {
    @RequestMapping(method = RequestMethod.GET, value = "/customerslastvisit")
    ResponseEntity customersLastVisit(
            @RequestParam(value = "from", required = true) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date from,
            @RequestParam(value = "to", required = true) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date to);
}
</code></pre>

<p>Generally, almost copy-paste. And now somewhere in my boot App, I use that:</p>

<pre><code>DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
ResponseEntity response = inboundACustomersClient.customersLastVisit(formatter.parse(formatter.format(from)),
        formatter.parse(formatter.format(to)));
</code></pre>

<p>And, what I get back is that </p>

<blockquote>
  <p>nested exception is
  org.springframework.core.convert.ConversionFailedException: Failed to
  convert from type [java.lang.String] to type
  [@org.springframework.web.bind.annotation.RequestParam
  @org.springframework.format.annotation.DateTimeFormat java.util.Date]
  for value 'Sun May 03 00:00:00 CEST 2015';</p>
  
  <p>nested exception is java.lang.IllegalArgumentException: Unable to
  parse 'Sun May 03 00:00:00 CEST 2015'</p>
</blockquote>

<p>So, the question is, what am I doing wrong with request, that it doesn't parse to "date-only" format before sending to my API? Or maybe it is a pure Feign lib problem?</p>