Skip to content
Advertisement

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 something like: Is

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: However, when I bundle it as a jpackage image (./gradlew jpackageImage using Gradle and the

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 do the following, using Strings: Why only some

How to create Currency instance with non ISO 3166 country like en_UK?

In my app, I get the user’s default locale using Locale.getDefault() and then pass that to Currency.getInstance(Locale). It mostly works, but I have started getting reports from users which show the following IllegalArgumentException in the stack trace: Caused by: java.lang.IllegalArgumentException: Unsupported ISO 3166 country: en_UK at java.util.Currency.getInstance(Currency.java:81) at org. I expected Android to only return valid locales, but that is

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 solution for that? The need is that I want to store some

Advertisement