Java 春季日期格式

Java 春季日期格式,java,spring,datetime,spring-boot,Java,Spring,Datetime,Spring Boot,我有一个angular应用程序,它会给我发送这样的日期dd/MM/yyyy。 我想在数据库中插入这个日期。 这是我的实体 @Entity public class Individu implements Serializable { @Id private String nui; private int civility; private String lastName; private String useName; private Stri

我有一个angular应用程序,它会给我发送这样的日期dd/MM/yyyy。 我想在数据库中插入这个日期。 这是我的实体

@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;
但当我运行SpringBootApp时,我总是会出现以下错误:

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")); 

有人能帮我解决吗?

你需要
@JsonFormat

@JsonFormat(pattern="dd/MM/yyyy")
private Date birthDate;

如果删除
@DateTimeFormat
注释并更改为,会发生什么情况?我有相同的错误请求。解决方案是使用@JsonFormat,比如下面的descripe。我也可以在这个日期中解析yyyy-MM-dd这样的日期。例如,要有一个像@JsonFormat(pattern=“dd/MM/yyyy,yyyy-MM-dd”)这样的JsonfFromat?