Passing date to request param in Spring MVC
Solution 1:
Use @DateTimeFormat("MMddyyyy")
public @ResponseBody List<RecordDisplay> getRecords(
@RequestParam(value="userID") Long userID,
@RequestParam(value="fromDate") @DateTimeFormat(pattern="MMddyyyy") Date fromDate,
@RequestParam(value="toDate") @DateTimeFormat(pattern="MMddyyyy") Date toDate) {
Solution 2:
This is now @DateTimeFormat as well which supports some common ISO formats
Solution 3:
Use @DateTimeFormat(pattern="yyyy-MM-dd") where yyyy is year, MM is month and dd is date
public @ResponseBody List<Student> loadStudents(@DateTimeFormat(pattern="yyyy-MM-dd") Date birthDay) {
...
}