Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

My Locale

 
Ranch Hand
Posts: 333
Firefox Browser Windows XP Java
  • Mark post as helpful
  • send pies
  • 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: 607
Firefox Browser Spring Java
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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: 10777
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Nice.
 
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic