Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Different Locale's , same JVM

 
Graeme Byers
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reading the Locale class I thought of this hypothetical problem.
"I am writing a program for use in both the UK head office and German branch office. We have a UK run and a separate German run on the same UK JVM. The reports include country name. Reports from the UK run should print "Germany" , reports from the German run should print "Deutchland".
A command line arg UK or DE indicates the run type (default UK).
If DE then setDefault to Deutchland then reset at EOJ to UK might work.
But what about concurrently running jobs ? How long does setDefault last , if I do not reset it (program abends) ?
Can the "variant" string be used to solve this problem ie. set it to "Deutchland" ? How is it set - no setVariant()."

I notice S&B page 468 (System.out.println where appropriate) :
Locale locBR = new Locale ("pt" , "BR") ;
locBR .getDisplayCountry() ; // Brazil
locBR .getDisplayCountry(locBR) ; // Brasil

Finally, just what is this all about ?
Locale currentLocale = Locale.getDefault(); // en_GB
currentLocale = new Locale( "en_GB" ); // en_gb
currentLocale = new Locale( "en" , "UK" ); // en_UK
currentLocale = Locale.UK ; // en_GB
Thank you
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15359
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Locale.setDefault() only sets the locale for the currently running JVM. If you stop the program and restart it, the setting is gone - it doesn't get stored anywhere.

Even if you start two Java processes (in different JVMs) and you call Locale.setDefault() in one of them, it will not affect the other one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic