I have a requirement for parsing ISO8601 formatted strings in Java with various levels of accuracy. Some examples of the string I need to parse are:
You can create a DateTimeFormatter with DateTimeFormatterBuilder, which has a method called parseDefaulting(). parseDefaulting() could set the default value if there is no matching.
DateTimeFormatter
DateTimeFormatterBuilder
parseDefaulting()