Java Text x could not be parsed:Unable to obtain LocalDateTime f
問題描述:
java.time.format.DateTimeParseException: Text '2023-08-18' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 2023-08-18 of type java.time.format.Parsed
問題分析:
1、不能直接把'2023-08-18'字符串轉(zhuǎn)換為L(zhǎng)ocalDateTime。
解決辦法:先把'2023-08-18'字符串轉(zhuǎn)換為L(zhǎng)ocalDate,然后再把LocalDate轉(zhuǎn)換為L(zhǎng)ocalDateTime。
注:
有關(guān)CustomDateUtil.toLocalDateTime的源代碼請(qǐng)查看gitee的xudong_master項(xiàng)目的master分支。
https://gitee.com/xudong_master/xudongbase/tree/master
標(biāo)簽: