File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes new Locale() from country code, but no lang code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "new Locale() from country code, but no lang code?" Watch "new Locale() from country code, but no lang code?" New topic
Author

new Locale() from country code, but no lang code?

David Balažic
Ranch Hand

Joined: May 15, 2008
Posts: 86
Hi!

Is it possible to create a Locale object based only on country code?

java.util.Locale() has either one parameter, the language, or two, lang+country.

In my situation I have a country code, but no lang code.

Is there some getDefaultLanguage(String countryCode) method, that would return the default language for a country?

In short:
- I have : String countryCode
- I need : a Locale object for that country, with the "default" language for that country ("de" for "DE" and "AT", "en" for "GB" etc)

Regards,
David
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
There is no default mechanism for that. However, you could write your own function for this.



JDBCSupport - An easy to use, light-weight JDBC framework -
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: new Locale() from country code, but no lang code?