How to parse case-insensitive strings with jsr310 DateTimeFormatter?

This alternative is usefull for initializating static variables:

DateTimeFormatter myFormatter = new DateTimeFormatterBuilder()
                               .parseCaseInsensitive()
                               .appendPattern("dd-MMM-yyyy")
                               .toFormatter(Locale.ENGLISH);

And there is... according to the User Guide (offline, see JavaDoc instead), you should use DateTimeFormatterBuilder to build a complex DateTimeFormatter

e.g.

DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
builder.parseCaseInsensitive();
builder.appendPattern("dd-MMM-yyyy");
DateTimeFormatter dateFormat = builder.toFormatter();

Tags:

Java

Jsr310