This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes getting the timezone from the request Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "getting the timezone from the request " Watch "getting the timezone from the request " New topic
Author

getting the timezone from the request

Renato Losio
Ranch Hand

Joined: Nov 23, 2005
Posts: 99
hello.

is there any way to retrieve the user / browser timezone from the HTTP headers in the request?

cheers

renato


Renato Losio - www.arsenio.it - renatoweb@arsenio.it
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56204
    
  13

Have you inspected the headers?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Renato Losio
Ranch Hand

Joined: Nov 23, 2005
Posts: 99
Well, I tried, but I could not find anything useful (or may be I am not looking for the correct info):



Is there any way to have the info from the request.getLocale()? I didn't think so but may be I'm worng...

cheers

renato
Sunil Vasudevan
Ranch Hand

Joined: Mar 05, 2007
Posts: 107
The method request.getLocale() will give you a Locale object.

Using this object, you can call getter methods to get the language, country etc. But this will not give you a timezone (At least from my knowledge).

A workaround would be to use JavaScript.

In your JSP, have a hidden form variable which will be set to the the timezone from the client system.

A sample javascript code that would get you the timezone offset is shown below:


The hidden form value can be retrieved from your request object and you can do the necessary processing.
[ March 14, 2007: Message edited by: Sunil Vasudevan ]

Sunil.V<br />SCJP2, SCWCD1.4, SCBCD1.3
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: getting the timezone from the request
 
Similar Threads
Intenationalisation: TimeZone support
Calendar
java.sql.ResultSet getTimestamp Locale issue
How do i get timezone info from the HTTPServletRequest
setting Timezone for web application