在使用日期控件时,向Controller中进行传值时会报错如下的错误:
所以我们要进行一下日期的转换。在Controller中初始化一下日期的格式。
@InitBinder
public void initBinder(WebDataBinder binder){
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm"); //时间格式
binder.registerCustomEditor(Date.class, "begintime", new CustomDateEditor(timeFormat, false));
binder.registerCustomEditor(Date.class, "endtime", new CustomDateEditor(timeFormat, false));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); //日期格式
binder.registerCustomEditor(Date.class, "setuptime", new CustomDateEditor(dateFormat, true));
}