aspose file tools*
The moose likes Beginning Java and the fly likes Different Locale's , same JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Different Locale Watch "Different Locale New topic
Author

Different Locale's , same JVM

Graeme Byers
Ranch Hand

Joined: Apr 16, 2004
Posts: 127
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

Joined: Aug 16, 2005
Posts: 14352
    
  22

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
Don't get me started about those stupid light bulbs.
 
subject: Different Locale's , same JVM