> 文档中心 > Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.time.LocalDateTim

Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.time.LocalDateTim

报错解决:Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalDateTime' for property 'xxx'

目录

简单描述一下报错然后给出解决方案。

报错描述

Failed to convert property value of type ‘java.lang.String’ to required type ‘java.time.LocalDateTime’ for property ‘xxx’

解决方案

在实体类的对应属性名上添加@DateTimeFormat注解,如下:

/**     * 交付日期     */    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")    private LocalDateTime deliveryDate;

结尾

有问题或者有更好的方案欢迎评论或私信,一起交流进步。