I'm trying to format a date in Java in different ways based on the given locale. For instance I want English users to see "Nov 1, 2009" (formatted by "MMM d, yyyy") and Norwegian users to see "1. nov. 2009" ("d. MMM. yyyy").
The month part works OK if I add the locale to the SimpleDateFormat constructor, but what about the rest?
I was hoping I could add format strings paired with locales to SimpleDateFormat, but I can't find any way to do this. Is it possible or do I need to let my code check the locale and add the corresponding format string?
This will display the date according to user's current locale:
Dec 31, 1969 7:00:02 PM
Dec 31, 1969
Java 8 Style for a given date