0

So I am trying to parse:

DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
TemporalAccessor parse = dateTimeFormatter.parse("20180521073438514");

And I receive the following error: "Text '20180521073438514' could not be parsed at index 0"

But when I try to add sth that will separate "ss" and "SSS" it works:

DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss.SSS");
TemporalAccessor parse = dateTimeFormatter.parse("20180521073438.514");

Am I missing some kind of delimiter to separate "ss" and "SSS"?

Marcin Majewski
  • 1,007
  • 1
  • 15
  • 30
  • By the way, it's [safer to use `u` instead of `y`](https://stackoverflow.com/questions/41177442/uuuu-versus-yyyy-in-datetimeformatter-formatting-pattern-codes-in-java). – MC Emperor Apr 15 '19 at 12:19

1 Answers1

1

This is a bug in Java 8 which was fixed in Java 9. Have a look at the official bug report https://bugs.openjdk.java.net/browse/JDK-8031085

BluesSolo
  • 608
  • 9
  • 28