initBinder,对日期修改

来源:互联网 发布:哈利波特魔杖淘宝 编辑:程序博客网 时间:2024/05/21 09:52


java ——@InitBinder

@InitBinder    
public void initBinder(WebDataBinder binder) {    
       SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM d yyyy HH:mm:ss",Locale.ENGLISH);    
       dateFormat.setLenient(false);
       binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));    
}

注意:1.英文的文字 需要使用 MMM解析,不能使用 MM
         2.要解析英文文字,需要把国家设为英国,Locale.ENGLISH

0 0