@RequestMapping(value = "/getSettlements", method = RequestMethod.GET, headers = "Accept=application/json")
public @ResponseBody
Collection<Settlement> getSettlements
(@RequestParam(value = "startDate") String startDate,
@RequestParam(value = "endDate") String endDate,
@RequestParam(value = "merchantIds", defaultValue = "null") String merchantIds)
How to give today's date in defaultValue ? It only takes constant.
If you are using LocalDate
, you can create a default value like this:
@RequestParam(name = "d", defaultValue = "#{T(java.time.LocalDate).now()}", required = true) LocalDate d)
@InitBinder
public void initBinder(WebDataBinder binder) throws Exception {
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
final CustomDateEditor dateEditor = new CustomDateEditor(df, true) {
@Override
public void setAsText(String text) throws IllegalArgumentException {
if ("today".equals(text)) {
setValue(new Date());
} else {
super.setAsText(text);
}
}
};
binder.registerCustomEditor(Date.class, dateEditor);
}
@RequestParam(required = false, defaultValue = "today") Date startDate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With