package com.lai.boss.common.utils;
public class CustomDateEdtor implements WebBindingInitializer{
public void initBinder(WebDataBinder binder, WebRequest request) {
DateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
try{
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateTimeFormat, true));
}catch (Exception e){
try {
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
} catch (Exception e2) {
reuturn null;
}
}
}
}
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<bean class="com.lai.boss.common.utils.CustomDateEdtor"/>
</property>
</bean>