Example: In the class Currency
there is a static method getInstance(Locale locale)
.
However If I write something like:
Currency currency = Currency.getInstance(Locale.forLanguageTag("it"));
It gives an exception (IllegalArgument..)
On the other hand:
Currency currency = Currency.getInstance(Locale.forLanguageTag("it-IT"));
Compiles without problem.
Can we safely say that without the country code the locale it's incomplete?
Note that specifying the only language it's a valid option to construct a Locale in some circumstances es:
Locale localize = Locale.forLanguageTag("it");
System.out.println(localize.getDisplayName());
You can have a Locale that represents just a language without a country, that's perfectly valid.
But you cannot get a currency from a language, since currencies are related to countries, not languages. The country of Italy does have currency, the Italian language does not...