29.controller 继承接受Date类型
作者:
木有鱼丸啦 | 来源:发表于
2019-02-18 13:26 被阅读0次@Component
public class BaseController {
@InitBinder
public void initBinder(WebDataBinder dataBinder) {
dataBinder.registerCustomEditor(
Date.class,
new PropertyEditorSupport() {
@Override
public void setAsText(String value) {
try {
setValue(new SimpleDateFormat("yyyy-MM-DD HH:mm:ss").parse(value));
} catch (ParseException e) {
setValue(null);
}
}
/* @Override
public String getAsText() {
return new SimpleDateFormat("YYYY-MM-DD HH:mm:ss").format((Date) getValue());
}*/
});
}
}
本文标题:29.controller 继承接受Date类型
本文链接:https://www.haomeiwen.com/subject/ondaeqtx.html
网友评论