Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Locale Class

 
Murat Balkan
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In one of the mocks, it says,

"This class is used to get info about the local country such as the country name and language"

The answer is java.util.Locale class. However, I couldnt see any method regarding this.
For example from the javadoc,

getCountry
public String getCountry()Returns the country/region code for this locale, which will either be the empty string or an upercase ISO 3166 2-letter code.

theres no no arg constructor for this class.Instead you give your locale to the class but this question says I can see current language but from where?
Any comments?
Thanks
Murat
 
C Chavan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you read JavaDoc carefully, you will find the answer. here is some text from there -

The Locale class provides a number of convenient constants that you can use to create Locale objects for commonly used locales. For example, the following creates a Locale object for the United States:

Locale.US

Once you've created a Locale you can query it for information about itself. Use getCountry to get the ISO Country Code and getLanguage to get the ISO Language Code. You can use getDisplayCountry to get the name of the country suitable for displaying to the user. Similarly, you can use getDisplayLanguage to get the name of the language suitable for displaying to the user. Interestingly, the getDisplayXXX methods are themselves locale-sensitive and have two versions: one that uses the default locale and one that uses the locale specified as an argument.

there is also static Locale.getDefault() method that returns Locale object for your system's default locale.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic