• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Locale Class

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using Locale's getAvailableLocales() method I can list all locales in Java Virtual Machine.Is there a way to add new Locale to Java Virtual Machine ?.Thank You
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at the implementation of java.util.Locale.getAvailebleLocales() (JSE 5.0):

The class LocaleData has the fully qualified name sun.text.resources.LocaleData and the source code for this is unfortunately no publically available. Browsing through the OpenJDK makes me believe that the list of available locale should be defined at compile-time. If this is correct there is now way of edit this list at run time.

You can however define your own locale using one of the constructors in the Locale class, and use this as input to the java.util.Locale.setDefault(Locale) method (and of course to whatever method that requires a Locale object as input).
 
Duleep Thivanka
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.But I want to install a new locale.How I can do that.setDefault method doesn't work because before that I want to install a new locale.
 
Sheriff
Posts: 28333
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should be pretty clear from the API documentation that the Locale class doesn't have any methods to install a new locale.

If you then click on the "Use" button at the top of the documentation page for Locale, that shows you everything in the standard API which uses Locale. You can check for yourself that there's nothing in this long list which installs a new Locale either.

An interesting thing you might notice in the list is that there are methods whose descriptions are like, for example, "Gets the date formatter with the given formatting style for the given locale". That implies that internally a Locale has a whole lot more baggage attached to it -- date formatters, number formatters, collators, and so on. You can't define any of that when you create a new Locale but the built-in Locales do have it.

Even the String class has a toLowerCase(Locale) method which uses the rules of the Locale for lower-casing. You wouldn't have any way of dealing with that, either. So installing a new Locale wouldn't be all that useful any way, since you don't have a way of specifying all those Locale-dependent objects and behaviours.
 
Duleep Thivanka
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your thoughts.
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic