Hi,
I'm attaching a class I wrote because it may help others, and also to
get comments about the wisdom of doing some like this.
I want to be able to tailor the HTML output of my servlets to the time
zone that the user is from. I also want to be able to make the format
in which dates are printed as normal for the user.
This class, ClientInfo, takes a ServerRequest paramter in its
constructor. It parses out the Top Level Domain, and uses that to
create appropiate Locale and SimpleDateFormat objects.
I'm not sure about a couple of things, though:
- I've only made mappings for the default locales that are defined in
the Java API. What would I do if I wanted to include support for more
locales? Write the locales myself? Anyone have any examples of this?
- Is it really necessary to set up a mapping between TLD and locale like
I'm doing? Could that be done in a more scalable, automatic way?
Thanks for any comments,
Robb
ClientInfo.java