Skip to content

Tag: locale

String input of weekdays in German to Localdate

I have a string input of weekdays in German and need to get the next Localdate after today which corresponds to the given weekday string. If for example the input is Montag (Monday) I need the output as Localdate of 2022-05-16 which is the next Monday after today. If the input was in english I could do someth…

Java program uses wrong locale when jpackaged

I am parsing strings representing German-style numbers (i.e., decimal comma and optional full stop for grouping thousands), e.g., “2.804,13”; this is just done using a DecimalFormat based on my desired Locale: This gives the desired output, e.g., when compiled and run from the command line: Howeve…

Why Java locales are not constants?

Java supports the Locales shown in this link. But I can’t figure out why only some countries such as France, Canada, China and United States and some languages such as Italian, Japanese and German have constants for their locales. Everytime a need a locale, I consult the table of supported locales and d…

How to get Locale from its String representation in Java?

Is there a neat way of getting a Locale instance from its “programmatic name” as returned by Locale’s toString() method? An obvious and ugly solution would be parsing the String and then constructing a new Locale instance according to that, but maybe there’s a better way / ready soluti…