Setting Default Locale Example in Java
Locale can be set also in our java programs by using the method setDefault() of Locale class. In this example we have set the default locale value of our Locale with the Locale.ITALY.
In our example of setting default locale value we can get the value of default locale by using getDefault() method. Here it is English and now we have to change it with our Locale with the use of setDefault() method of Locale class.
Locale locale = Locale.getDefault(); creates Locale class object by getting the default locale.
locale = Locale.ITALY;
Above lines of code sets locale to ITALY and then sets the default locale value to this locale. Here is the full example code of SettingLocale.java as follows:
Before setting, Locale is = en_US
After setting, Locale is = it_IT
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Java Set Default Locale
Post your Comment