SimpleDateFormat with German Locale – Java 8 vs Java 10+

I don’t say it’s a nice solution, but it seems to be a way through. Map<Long, String> dayOfWeekTexts = Map.of(1L, “Mo”, 2L, “Di”, 3L, “Mi”, 4L, “Do”, 5L, “Fr”, 6L, “Sa”, 7L, “So”); Map<Long, String> monthTexts = Map.ofEntries(Map.entry(1L, “Jan”), Map.entry(2L, “Feb”), Map.entry(3L, “Mär”), Map.entry(4L, “Apr”), Map.entry(5L, “Mai”), Map.entry(6L, “Jun”), Map.entry(7L, “Jul”), Map.entry(8L, “Aug”), Map.entry(9L, “Sep”), …

Read more

SimpleDateFormat warning To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(),

You are currently using the SimpleDateFormat(String) constructor. This implies the default locale and as the Locale documentation tells you, be wary of the default locale as unexpected output can be produced on various systems. You should instead use the SimpleDateFormat(String, Locale) constructor. It is going to take in an additional parameter – the locale you …

Read more