This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSP and the fly likes Displaying date and time locale specific Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Displaying date and time locale specific" Watch "Displaying date and time locale specific" New topic
Author

Displaying date and time locale specific

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Hi,

My application is accessed across the globe. I am setting the date and time in java layer and displaying it in JSP. The server is running in US. When ever someone outside US wants to look at the date and time on screen, they will be looking at the US time and date. I want it be locale specific. I guess it should be done at JSP page level. Can you please give inputs on how to implement the date and time for locale specific.


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61299
    
  66

You have the link to the JSTL Spec in your sig, the <fmt:formatDate> tag will allow you to specify the time zone to use for emitting the formatted date.

Of course you need to get your users to tell you what time zone they are in. Most sites with registration make this part of the member profile.
[ January 09, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Thanks for your reply Bear.

Is it possible to achieve the same using any struts tags.



Of course you need to get your users to tell you what time zone they are in. Most sites with registration make this part of the member profile.



Users will be logging into the application using sso. Can't we just render the page as per user's locale specific time.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61299
    
  66

Originally posted by Vishnu Prakash:
Is it possible to achieve the same using any struts tags.

Not that I'm aware of, but I ditched Struts long ago. So I may not be "in the know" regarding anything that's been added since.

Can't we just render the page as per user's locale specific time.

How would you know what it is? The Date header on a request typically reports the timestamp using GMT.

You could use some JavaScript magic (since the JS runs on the client) to try and figure it out. Perhaps as part of the login, you can have the page add a hidden input that reports the timezone offset? Not something I've done, but it sounds like a good theory/starting point.
[ January 10, 2008: Message edited by: Bear Bibeault ]
 
 
subject: Displaying date and time locale specific