<bean id="customDateEditor"
class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.sql.Timestamp">
<bean class="my.util.TimestampEditer" />
</entry>
</map>
</property>
</bean>
public class TimestampEditer extends PropertyEditorSupport {
private String format = "yyyy-MM-dd hh:mm:ss";
public TimestampEditer() {
}
@Override
public void setAsText(String text) throws IllegalArgumentException {
SimpleDateFormat sdf = new SimpleDateFormat(format);
try {
this.setValue(new Timestamp(sdf.parse(text).getTime()));
} catch (ParseException e) {
e.printStackTrace();
}
}
}
日期属性编辑工具类,主要格式化成需要的日期格式类型
附:http://blog.csdn.net/buyaore_wo/article/details/8100608?utm_source=tuicool