java.util.Locale constructor does not workwhen using "gsw" as a Swiss language locale in Java 8

Viewed 153

The context:

A customer asked me to help him with a method to format a Joda DateTime with a Locale specified as a parameter.

The problem:

Using "gsw" (Swiss German) as a language does not seem to have an effect on the translation (falls back to English in my case). "gsw" is part of ISO639-2 (which is ISO639 alpha-3, which the Java locale says it supports, https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html).

I verified to be 100% sure and gsw is part of alpha-3, but it wasn't part of alpha-2 (ISO639-1): https://www.loc.gov/standards/iso639-2/php/English_list.php I've tried with other languages which are part of alpha-3 but were not present in alpha-2 and I see the same strange behavior. Have I might not read well enough the Locale helpcenter?

The code: //all are types belong to joda.time, except Locale, which is java.util

DateTimeZone dtZone = DateTimeZone.forID(IANATimezone);
DateTime dtus = dateTime.withZone(dtZone);
Locale locale = new Locale(Language, Region);
DateTimeFormatter dtf = DateTimeFormat.fullDateTime().withLocale(locale); 
0 Answers
Related