I have the following line in my java
code where I am trying to format a date string
ZonedDateTime zonedDateTime= ZonedDateTime.ofInstant(instant, tz);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm aa");
return zonedDateTime.format(formatter);
At line 2 , I am getting this error:
java.lang.IllegalArgumentException: Too many pattern letters: a
at java.time.format.DateTimeFormatterBuilder.parseField(DateTimeFormatterBuilder.java:1774)
How can I create a format string for DateTimeFormatter.ofPattern
that will give e.g:
2023-04-21 7.00pm
CodePudding user response:
Use one a
As the error describes, you have used too many a
character codes.