Java8 DateTimeFormatter am/pm
Note that the case of AM
and PM
depends on your locale!
So if your locale is US it's expected to be upper case, but if it's UK it's expected to be lower case.
See: Localize the period (AM/PM) in a time stamp to another language for more details.
a
expects either PM
or AM
in upper case. To get a case insensitive formatter you need to build it manually:
DateTimeFormatter fmt = new DateTimeFormatterBuilder()
.parseCaseInsensitive()
.appendPattern("EEE MMM dd, yyyy h:mma z")
.toFormatter(Locale.US);
Note that you will get a new error because the 16th of July is not a Wednesday.