2.在controlle中配置 @InitBinder public void abc(WebDataBinder binder) { DateFormat df=new SimpleDateFormat("yyyy-MM-dd"); binder.registerCustomEditor(Date.class, new CustomDateEditor(df, true)); } 3.自定义一个类 可以设置为全局时间转换
@ControllerAdvicce public class SpringControllerAdvicce{ @InitBinder public void abc(WebDataBinder binder) { DateFormat df=new SimpleDateFormat("yyyy-MM-dd"); binder.registerCustomEditor(Date.class, new CustomDateEditor(df, true)); } }