LocalDateTime注解后不能新增修改

Blade 未结 1 1057
SophieRoyal
SophieRoyal 剑者 2020-06-28 13:59

一、该问题的重现步骤是什么?

  1. 我在字段上加了注解,时间可以正常展示去除了T,但是我新增却因为字符不匹配报错

  2. @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    private LocalDateTime installTime;

前端插入字符类型为

installTime: "2020-06-27T16:00:00.000Z"


二、你期待的结果是什么?实际看到的又是什么?

展示能正常展示去除T,新增修改能正常入库

三、你正在使用的是什么产品,什么版本?在什么操作系统上?

bladex boot win10

四、请提供详细的错误堆栈信息,这很重要。

消息不能读取:JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String "2020-06-27T16:00:00.000Z": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2020-06-27T16:00:00.000Z' could not be parsed at index 10; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.LocalDateTime` from String "2020-06-27T16:00:00.000Z": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2020-06-27T16:00:00.000Z' could not be parsed at index 10
 at [Source: (PushbackInputStream); line: 1, column: 218] (through reference chain: org.springblade.longchi.device.entity.OptoSensor["installTime"])

五、若有更多详细信息,请在下面提供。

我如果没有添加注解,可以正常新增修改,但是展示就是带了T;

添加了注解,展示去除了T,但是新增修改又不行了

1条回答
  • 2020-06-28 14:06

    前端应该按照您标注的格式传回后端,此例应为"2020-06-27 16:00:00"

    作者追问:2020-06-28 14:17

    谢谢,我本来是不打算叫前端这边修改,我这边配置转换看能不能直接转换。但是试用了好几种方法都没效果。我等下叫前端一起修改看看

    0 讨论(0)
提交回复