I use custom editors to convert String to date. My code is below
@InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); }
When I enter the date in "yyyy-MM-dd", then insert it.
But when I enter the empty, it throws an exception
The nested exception is java.lang.IllegalArgumentException: Failed to parse date: Unmatched date: ""
I can not confirm this.
If I give some other format, it will also not be able to parse.
user616114
source share