请求主体中List <LocalDateTime>的反序列化

我想向我的Spring Boot应用程序的RestController发送一个发布请求:

curl -H“ Content-Type:application / json” -X POST“ localhost:8080 / api” -d'{“ time”:“ 2020-05-17 18:19:00”}'

I think @JsonFormat can be utilized to parse the LocalDateTime field as:

public class FooDTO implements Serializable {
    @NotNull
    @Future   
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime time; 
}

So how to deserialize List<LocalDateTime> with annotations? This doesn't work:

public class FooDTO implements Serializable {
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private List<@NotNull @Future LocalDateTime> time;
}

提前致谢。

评论