Formatting a LocalDate
in Java 8 using a specific Locale
can be achieved like this:
DateTimeFormatter.ofLocalizedDate(FormatStyle.S
You need to use DateTimeFormatter#ofPattern
For YearMonth
YearMonth source = YearMonth.now();
DateTimeFormatter english = DateTimeFormatter.ofPattern("MMMM, yyyy", Locale.ENGLISH);
DateTimeFormatter german = DateTimeFormatter.ofPattern("MMMM yyyy", Locale.GERMAN);
System.out.println(source.format(english));
System.out.println(source.format(german));
For MonthDay
MonthDay source = MonthDay.now();
DateTimeFormatter english = DateTimeFormatter.ofPattern("MMMM dd", Locale.ENGLISH);
DateTimeFormatter german = DateTimeFormatter.ofPattern("dd. MMMM", Locale.GERMAN);
System.out.println(source.format(english));
System.out.println(source.format(german));