Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying date and time locale specific

 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic