Java.time.DateTimeFormatter cannot parse without delimiters

java.time.LocalDateTime success = java.time.LocalDateTime.parse("20 01 2014 15 36 21 234",java.time.format.DateTimeFormatter.ofPattern("dd MM yyyy HH mm ss SSS"));             
java.time.LocalDateTime fails   = java.time.LocalDateTime.parse("20012014153621234",java.time.format.DateTimeFormatter.ofPattern("ddMMyyyyHHmmssSSS"));

link: http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html

Question: It is obvious that the formatter / parser does not distinguish between fixed and variable elements. eg. d = "day of the month", used as "dd", can be one or two digits (for example, 8 or 18). Therefore, the analyzer does not use "fixed" lengths because it is trying to parse the next "element". But the "elements" are not separated, and parsing is not performed.

I'm right? Is there a fix for this?

Edit: Interestingly, this works:

java.time.LocalDate date1   = java.time.LocalDate.parse("20140120", java.time.format.DateTimeFormatter.ofPattern("yyyyMMdd"));
java.time.LocalTime time1   = java.time.LocalTime.parse("153621234", java.time.format.DateTimeFormatter.ofPattern("HHmmssSSS"));

but why not for Date + Time?

+4

All Articles