• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Different Locale's , same JVM

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic