Close

Spring MVC - @DateTimeFormat Examples

Spring MVC 

    @DateTimeFormat(pattern = "MM-dd-yyyy")
private Date tradeDate;
Original Post




    @RequestMapping(value = "{id}/paystubs", params = {"startDate", "endDate"})
public String handleRequest4 (
@PathVariable("id") String employeeId,
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) @RequestParam
("startDate") LocalDate startDate,
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) @RequestParam
("endDate") LocalDate endDate,
Model model) {

LOGGER.info("employee request by id and paystub dates : " +
employeeId + ", " + startDate + ", " + endDate);
model.addAttribute("msg",
"employee request by id and paystub dates : " + employeeId +
", " + startDate + ", " + endDate);
return "my-page";
}
Original Post




See Also