ThreeTen / threetenbp

Backport of functionality based on JSR-310 to Java SE 6 and 7. This is NOT an implementation of JSR-310.
http://www.threeten.org/threetenbp/
BSD 3-Clause "New" or "Revised" License
552 stars 139 forks source link

DateTimeFormatter gives a different result (first time number, second time word - I expect word) #152

Closed bonusdev closed 2 years ago

bonusdev commented 3 years ago
val dateTimeFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.ENGLISH)
val a = dateTimeFormatter.format(LocalDate.of(2022, Month.MARCH, 1))
val b = dateTimeFormatter.format(LocalDate.of(2022, Month.MARCH, 1))
val c = dateTimeFormatter.format(LocalDate.of(2022, Month.MARCH, 1))

so, "a" is "1 3 2022", "b" and "c" is "1 March 2022". I need "1 March 2022" result altime...

sschaap commented 2 years ago

Not reproducible on OpenJDK. Needs more information to reproduce.

DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.ENGLISH);
String a = dateTimeFormatter.format(LocalDate.of(2022, Month.MARCH, 1));
String b = dateTimeFormatter.format(LocalDate.of(2022, Month.MARCH, 1));
String c = dateTimeFormatter.format(LocalDate.of(2022, Month.MARCH, 1));

System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("c = " + c);

outputs

a = 1 March 2022
b = 1 March 2022
c = 1 March 2022
jodastephen commented 2 years ago

There might be a race condition somewhere, but without more info on the JDK version and OS etc there isn't much to investigate.

jodastephen commented 2 years ago

Closing due to lack of feedback