How to dateFormatter Timestamp and Date in coincide

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

but it's also error because I used Timestamp too:

Field error in object 'identitas' on field 'dupd': rejected value [2013-12-13 11:19:33.0]; codes [typeMismatch.identitas.dupd,typeMismatch.dupd,typeMismatch.java.sql.Timestamp,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [identitas.dupd,dupd]; arguments []; default message [dupd]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.sql.Timestamp' for property 'dupd'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [java.sql.Timestamp] for property 'dupd': PropertyEditor [org.springframework.beans.propertyeditors.CustomDateEditor] returned inappropriate value of type [java.util.Date]]

How to dateformatted Date and Timestamp in coincide?

0

There are 0 answers