如何将dateFormatter时间戳和日期重合

时间:2013-12-13 04:30:03

标签: java spring timestamp spring-mvc-initbinders

@InitBinder
public void initBinder(WebDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    dateFormat.setLenient(false);
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}

但它也是错误的,因为我也使用了Timestamp:

  

字段'dupd'上的对象'identitas'中的字段错误:被拒绝的值[2013-12-13 11:19:33.0];代码[typeMismatch.identitas.dupd,typeMismatch.dupd,typeMismatch.java.sql.Timestamp,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable:codes [identitas.dupd,dupd];参数[];默认消息[dupd]];默认消息[无法将类型'java.lang.String'的属性值转换为属性'dupd'的必需类型'java.sql.Timestamp';嵌套异常是java.lang.IllegalArgumentException:无法将类型[java.lang.String]的值转换为属性'dupd'的必需类型[java.sql.Timestamp]:PropertyEditor [org.springframework.beans.propertyeditors.CustomDateEditor]返回不适当的类型[java.util.Date]]

如何日期格式化日期和时间戳重合?

0 个答案:

没有答案
相关问题