Forum Stats

  • 3,837,375 Users
  • 2,262,252 Discussions
  • 7,900,266 Comments

Discussions

DateTimeFormatter am/pm java 9 case changed

e9039c51-3020-4140-ac24-51566819af0f
edited Aug 14, 2018 2:13AM in Java SE Early Access

Hi

When testing java 9+181 I encountered an issue with one of our tests

There's a change in behaviour for DateTimeFormatter with the pattern 'a' argument

Test case:

String formattedDate = DateTimeFormatter.ofPattern("a").format(LocalDateTime.now());
System.out.println(formattedDate);

assertThat(formattedDate).isEqualTo("PM");

Passed on java 8

Fails on java 9 with: 'pm'

Is this an intentional change?

The javadocs still say PM

DateTimeFormatter (Java SE 9 & JDK 9 )

Answers

  • Pallavi Sonal-Oracle
    Pallavi Sonal-Oracle Member Posts: 7
    edited Aug 14, 2018 2:13AM

    I am getting the same output in JDK 8u144 as well as 9-ea+181, here is the output on running the code provided by you:

    java version "9"

    Java(TM) SE Runtime Environment (build 9+181)

    Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

    PM

    I think the difference in the output of OP and my system is because of the difference in the locale. Can you let us know what is the default locale on your system.