In the Spring-boot project I try to pass as a request parameter a Date object and get this error:
Parameter value [1] did not match expected type [java.util.Date (n/a)]
This is the http-requset that i send:
http://localhost:8080/moneyManager/customer/actionBetweenDates?startDate=2019/07/01&endDate=2019/07/30
This is the fuction that trigger in the rest:
@RequestMapping(path="actionBetweenDates", method=RequestMethod.GET)
public Collection<Action> getActionByDate(@RequestParam Date startDate, @RequestParam Date endDate){
return customerService.getAllActionBetweenDate(getSession().getId(), startDate, endDate);
}
The function in rest trigger the function in service :
public Collection<Action> getAllActionBetweenDate(long customerId, Date startDate, Date endDate) {
Collection<MethodPayment> customerMethodPayments = methodPaymentRepository.findByCustomerId(customerId);
Collection<Action> customerActionByDates = new ArrayList<>();
for (MethodPayment mp : customerMethodPayments) {
customerActionByDates
.addAll(actionRepository.findByDateBetweenAndMethodPaymentId(mp.getId(), startDate, endDate));
}
return customerActionByDates;
}
The function in the service trigger the funcion in the repository:
Collection<Action> findByDateBetweenAndMethodPaymentId(long methodPaymentId, Date startDate, Date endDate);
What am I doing wrong?
Updating:
I finded the problem. the problem was related to the function found in actionRepository. The signature of the function first asks for two dates to compare between them and then id and I gave it opposite values. It's clear to me that after I got on it I would have had a problem with the date so the answers did help me. Thank you all!