Skip to content

Instantly share code, notes, and snippets.

@yanhua365
Created April 7, 2014 08:58
Show Gist options
  • Select an option

  • Save yanhua365/10016938 to your computer and use it in GitHub Desktop.

Select an option

Save yanhua365/10016938 to your computer and use it in GitHub Desktop.
在Spring MVC的Controller里注册日期参数的转换器
@InitBinder
protected void initBinder(HttpServletRequest request,
ServletRequestDataBinder binder) {
SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, null,
new CustomDateEditor(dateFormat, true));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment