Possible casing issue with DateTimeFormatter in JDK 15 on

Mark Derricutt mark at talios.com
Thu Apr 14 08:44:57 UTC 2022


Hey all,

I’ve just been working on finally migrating some of our code to at least,
build UNDER a JDK greater than 8 - and ran into a test case in my code base
that failed relating to (possibly) undocumented changes in the the
DateTimeFormatter.

In this case, it’s triggered when using the AM/PM specifier - such as in
h:mma - under JDK8 and JDK11 this renders out as PM but, in 15/16/17/18
this renders as pm.

The docs on
https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/time/format/DateTimeFormatter.html
merely
show PM as an *example*, but doesn’t specifically call out casing.

I’ve thrown a simple JBang based class/test on
https://gist.github.com/talios/23cb742a7ac5fe6f984abd56c2d65352

JDK8:

$ jbang run DateFormatTest.java
Oct 2, 12:20PM (Z)


JDK18:

$ jbang run DateFormatTest.java
Oct 2, 12:20pm (Z)
Formatting failed


Is this a bug, an undocumented change, something I’m overthinking to much
over and I should just adjust my tests to ignore case?

Cheers
Mark


-- 
"Great artists are extremely selfish and arrogant things" — Steven Wilson,
Porcupine Tree


More information about the discuss mailing list