1
@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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • can you please write or format your question properly ? –  Dec 13 '13 at 07:36
  • sorry i'cant speak english properly :) – user3097989 Dec 13 '13 at 09:31
  • Sounds as though you need to register a [SqlTimestampPropertyEditor](http://adfinmunich.blogspot.de/2011/04/how-to-write-sqltimestamppropertyeditor.html) for converting the Timestamp fields on your model. – Will Keeling Dec 13 '13 at 10:46

0 Answers0