I found an issue, down't know how to fix and explain it. Is it java bug or what? Why the first example works with milliseconds delimiter:
ZonedDateTime timeAsUTC1 = LocalDateTime.from(DateTimeFormatter.ofPattern("yyyyMMddHHmmss-SSS").parse("20190902165550-091")).atZone(ZoneId.of("UTC"));
System.out.println(timeAsUTC1);
But the second one without delimiter:
ZonedDateTime timeAsUTC2 = LocalDateTime.from(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").parse("20190902165550091")).atZone(ZoneId.of("UTC"));
System.out.println(timeAsUTC2);
fails with the following excpetion:
Exception in thread "main" java.time.format.DateTimeParseException: Text '20190902165550091' could not be parsed at index 0
at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)
at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1777)
My project db uses datetime as ID so it's is just a number, and i'd like to parse it.
Can't reproduce in ideone: https://ideone.com/XFnYFn I suppose it was fixed after java8 which i'm using