小编Aro*_*hi 的帖子

解析 LocalDate 但得到 DateTimeParseException;dd-MMM-uuuu

我正在尝试将 a 转换StringLocalDateusing DateTimeFormatter,但收到异常:

java.time.format.DateTimeParseException:无法在索引 5 处解析文本“ 2021-10-31 ”

我的代码是

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MMM-uuuu");
String text = "2021-10-31";
LocalDate date = LocalDate.parse(text, formatter);
Run Code Online (Sandbox Code Playgroud)

我正在尝试从输入日期转换2021-10-3131-Oct-2021.

java java-time localdate datetimeformatter datetimeparseexception

4
推荐指数
1
解决办法
856
查看次数