将字符串的日期转化为Date类型
在Hibernate中有一个非常简单的方法,不再需要你每次都去转换,你只要在你的类中引用了这个函数,它将自动的将需要转换的全部给你转化:
/** * Defined dateFormat(string to date) * * @param binder */@InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); }