Previous | Next | Trail Map | Internationalization | Setting the Locale

The Scope of a Locale

The Java platform does not support the notion of a global Locale. You can specify a default Locale, as described in the previous section, but you are not required to use the same Locale throughout your program. If you wish, you can assign a different Locale to every locale-sensitive object in your program. This is the case when you are writing multi-lingual applications, which can display information in multiple languages. For most applications, though, you'll set all of the locale-sensitive objects to the same Locale.

Distributed computing raises some interesting issues. For example, suppose you are designing an application server that will receive requests from clients in different countries. If the Locale for each client is different, what should be the Locale of the server? Perhaps the server is multi-threaded, and each thread is set to the Locale of the client it services. Or perhaps all data passed between the server and the clients should be locale-independent. Which design approach should you take? The answer depends on the requirements specific to your application, whether legacy systems are involved, and how much complexity you want to allow in your design. Theoretically, you could set every locale-sensitive object in the client and server to a different Locale. This wouldn't be practical, of course, but it does demonstrate the flexibility of Locale objects on the Java platform.


Previous | Next | Trail Map | Internationalization | Setting the Locale