java ZonedDateTime 毫秒部分解析错误
java ZonedDateTime parse error for milliseconds part
ZonedDateTime zdt3 = ZonedDateTime.parse("1999-09-09 09:09:09.999",
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.xxx"));
运行时错误:
Exception in thread "main" java.time.format.DateTimeParseException:
Text '1999-09-09 09:09:09.999' could not be parsed at index 20
如何解决我的问题?
参见ZonedDateTime
的doc:
A date-time with a time-zone in the ISO-8601 calendar system, such as
2007-12-03T10:15:30+01:00 Europe/Paris.
1999-09-09 09:09:09.999
不包含任何区域信息,它可能是 LocalDateTime
:
LocalDateTime zdt3 = LocalDateTime.parse("1999-09-09 09:09:09.999",
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
ZonedDateTime zdt3 = ZonedDateTime.parse("1999-09-09 09:09:09.999",
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.xxx"));
运行时错误:
Exception in thread "main" java.time.format.DateTimeParseException: Text '1999-09-09 09:09:09.999' could not be parsed at index 20
如何解决我的问题?
参见ZonedDateTime
的doc:
A date-time with a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00 Europe/Paris.
1999-09-09 09:09:09.999
不包含任何区域信息,它可能是 LocalDateTime
:
LocalDateTime zdt3 = LocalDateTime.parse("1999-09-09 09:09:09.999",
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));