LocalDateTime today = LocalDateTime.now();
String timeMedium = today.format(DateTimeFormatter
.ofLocalizedTime(FormatStyle.MEDIUM));
System.out.println("timeMedium = " + timeMedium);
In this code, we expect output something like that timeMedium = 1:12:50 AM
. It shows AM/PM in many pc with the same java version (16). The code should work the same as java 8 and above. But in my pc (MacOS Catalina), AM/PM never shows up.
It is also the same for the below code.
ZonedDateTime today = ZonedDateTime.now();
String timeMedium = today.format(DateTimeFormatter
.ofLocalizedTime(FormatStyle.LONG));
System.out.println("timeMedium = " + timeMedium);
Output will be something like that timeMedium = 1:11:35 a.m. EDT
. It works fine in Ubuntu 20.04. But in my mac it shows without AM/PM.
N.B.- My PC is setup with 12 hour time format.