`
jhyimu2005
  • 浏览: 181636 次
  • 性别: Icon_minigender_2
  • 来自: 苏州
社区版块
存档分类
最新评论

将字符串的日期转化为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));  
	}
1
2
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics