读书人

将字符串的日期转化作Date类型

发布时间: 2012-10-09 10:21:45 作者: rapoo

将字符串的日期转化为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));  }

读书人网 >软件架构设计

热点推荐