Setting the Locale |
The Java platform does not support the notion of a globalLocale
. You can specify a defaultLocale
, as described in the previous section, but you are not required to use the sameLocale
throughout your program. If you wish, you can assign a differentLocale
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 sameLocale
.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 theLocale
of the server? Perhaps the server is multi-threaded, and each thread is set to theLocale
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 differentLocale
. This wouldn't be practical, of course, but it does demonstrate the flexibility ofLocale
objects on the Java platform.
Setting the Locale |