I'm trying to write a Spring MVC GET controller that takes a Java 8 Instant as request parameter:
@GetMapping
@JsonView(OrderListing.class)
@Validated
public WebSeekPaginatedResultsDto<OrderListingDto> findAll(@Valid OrderSearchCommand orderSearchCommand) {
// Some code
}
with:
public class OrderSearchCommand {
private Instant dateCreatedStart;
private Instant dateCreatedEnd;
// Some other fields
}
I'm triggering a GET request from some React/Javascript code with something like that:
http://localhost:8080/mms/front/orders?dateCreatedStart=2017-05-31T22%3A00%3A00.000Z
Spring does not seem to like it and throws an error. Here is the error message:
Failed to convert property value of type 'java.lang.String' to required type 'java.time.Instant' for property 'dateCreatedStart';
nested exception is java.lang.IllegalStateException:
Cannot convert value of type 'java.lang.String' to required type 'java.time.Instant' for property 'dateCreatedStart': no matching editors or conversion strategy found
Any idea why I'm getting this?
Thank you