Syllaba Abou Ndiaye :
I have an angular app which send me a date like this dd/MM/yyyy. I would like to insert this date in the database. Here is my entity
@Entity
public class Individu implements Serializable {
@Id
private String nui;
private int civility;
private String lastName;
private String useName;
private String firstName;
@Temporal(TemporalType.DATE)
@DateTimeFormat(pattern="dd/MM/yyyy")
private Date birthDate;
but when i run my SpringBootApp i always have this error:
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.Date` from String "20/02/1990": not a valid representation (error: Failed to parse Date value '20/02/1990': Cannot parse date "20/02/1990": not compatible with any of standard forms ("yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss.SSS", "EEE, dd MMM yyyy HH:mm:ss zzz", "yyyy-MM-dd"));
Is some one have a solution for me?
xingbin :
You need @JsonFormat
:
@JsonFormat(pattern="dd/MM/yyyy")
private Date birthDate;