mercredi 11 mars 2015

Date format exception in spring

I am trying to pass date as an input from Chrome Rest Client but due to some reason API is throwing an exception, please have a look below :


Rest Client payload



{ "todoDT" : "17/12/2014" }



POJO class



public class MyCBO extends DComponent {

@DateTimeFormat(pattern="dd/mm/yyyy")
private Date todoDT;

public Date getTodoDT() {
return todoDT;
}
public void setTodoDT(Date todoDT) {
this.todoDT = todoDT;
}
}


& the exception is



INFO: Exception occurred while handling request :{} org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Can not construct instance of java.util.Date from String value '01/01/2014': not a valid representation (error: Failed to parse Date value '01/01/2014': Can not parse date "01/01/2014": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"))



Aucun commentaire:

Enregistrer un commentaire