Is there a way how to create JSR-310 formatter that is able to parse both following date/times with variable length of seconds fraction?
2015-05-07 13:20:22.
And this one works
DateTimeFormatter formatter
= new java.time.format.DateTimeFormatterBuilder()
.append( java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") )
.appendOptional(
new java.time.format.DateTimeFormatterBuilder()
.appendLiteral('.')
.appendValue( ChronoField.MICRO_OF_SECOND, 1, 6, SignStyle.NOT_NEGATIVE).toFormatter())
.toFormatter();