vektor
vektor

Reputation: 2926

How to get a less specific Locale in Java

Suppose I have Locale enUS = new Locale("en", "US");. Is there a way to extract the language locale from it, better/nicer than Locale en = new Locale(enUS.getLanguage()); ?

Upvotes: 1

Views: 148

Answers (1)

Stijn Geukens
Stijn Geukens

Reputation: 15628

Although I don't find the above too verbose myself commons.lang's LocaleUtils may look cleaner:

LocaleUtils.toLocale(enUS.getLanguage());

Upvotes: 4

Related Questions