• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

My Locale

 
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HELLO

I couldn't figure out this.I'm wondering what does it mean ? I were expecting default locale of my system but there is nothing.
Now what do i with that object? what is the use of that object, could you elaborate about it?


---------- Run ----------


Output completed (0 sec consumed) - Normal Termination
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why not use the getDefault method? http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Locale.html#getDefault%28%29
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In setRegion() , If region is null or the empty string, the region in the Builder returned is removed.
Same for setLanguage()

http://docs.oracle.com/javase/7/docs/api/java/util/Locale.Builder.html#setRegion%28java.lang.String%29
 
Bartender
Posts: 3323
86
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I couldn't figure out this.I'm wondering what does it mean ?


You have created a Locale with no region or language. This is the same as the Locale.ROOT locale.

I were expecting default locale of my system but there is nothing.


You need to do as Saifuddin Merchant has suggested.

Now what do i with that object?


That's entirely up to you.

what is the use of that object


See this thread https://coderanch.com/t/594833/java/java/ROOT-locale
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tony Docherty wrote:

I couldn't figure out this.I'm wondering what does it mean ?


You have created a Locale with no region or language. This is the same as the Locale.ROOT locale.

I were expecting default locale of my system but there is nothing.


You need to do as Saifuddin Merchant has suggested.

Now what do i with that object?


That's entirely up to you.

what is the use of that object


See this thread https://coderanch.com/t/594833/java/java/ROOT-locale



Can you show me API, which says it is ROOT LOCALE ? Would you elaborate it ?
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you read the thread I linked you to?
As for the API docs do a google for something like "Java Locale api docs 1.6"
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't find any evidence which says below statement creates a ROOT Locale object i.e. Locale.ROOT

Locale defaultLocale=new Locale.Builder().setRegion(null).setLanguage("").build();
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ankita modi. wrote:I didn't find any evidence which says below statement creates a ROOT Locale object i.e. Locale.ROOT


Me neither, but I did find:
"Builders can be reused; clear() resets all fields to their default values."
and a little look at the specific methods expands on that.

And if you're not prepared to take Tony's word for it (and he seems a fairly knowledgeable chap), then TEST IT.

Winston
 
Tony Docherty
Bartender
Posts: 3323
86
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apologies, I thought I'd copied an extract of the docs into the thread.

The docs for Locale.ROOT say "The root locale is the locale whose language, country, and variant are empty ("") strings."
And for Locale.Builder.setLanguage() and setRegion() they they say "Sets the language. If language is the empty string or null, the language in this Builder is removed." and "Sets the region. If region is null or the empty string, the region in this Builder is removed" respectively.

So Locale defaultLocale=new Locale.Builder().setRegion(null).setLanguage("").build(); creates a Locale without a region or language which is in essence the Locale.ROOT object.
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nice.
 
This parrot is no more. It has ceased to be. Now it's a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic