| Author |
How to get current date based on time zone or locale, or user preference?
|
josuva moorthy
Greenhorn
Joined: Apr 05, 2010
Posts: 11
|
|
My web application is deployed in the US I will get US time regardless of the client's country. But if the client is in India, he should get Indian time, either using the time zone or locale or user preference. What should I do?
Example : A user is doing a transaction from India morning 8.00 am .and user searches for the transaction he found the time is US date and time ,user get confused
So we need to change the time as local time .
What I need to do
Please help me
|
 |
harshvardhan ojha
Ranch Hand
Joined: Jul 26, 2007
Posts: 157
|
|
use Client Locale like
Locale clientLocale = request.getLocale();
Calendar calendar = Calendar.getInstance(clientLocale);
TimeZone clientTimeZone = calendar.getTimeZone();
|
 |
josuva moorthy
Greenhorn
Joined: Apr 05, 2010
Posts: 11
|
|
Thanks for your reply
If your having any sample code for this requirement or any link or any docs related to this
It would be helpful.
Thanks in advance
|
 |
harshvardhan ojha
Ranch Hand
Joined: Jul 26, 2007
Posts: 157
|
|
Hi josuva,
try this link
http://forums.devarticles.com/java-development-38/jsp-getting-the-client-system-date-and-time-to-display-on-19428.html
and let me know if you face any issue, i would be happy to help.
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
|
you can use java script to find client timezone offset and send to a server to calculate clients timezone
|
 |
josuva moorthy
Greenhorn
Joined: Apr 05, 2010
Posts: 11
|
|
Seetharaman Venkatasamy wrote:you can use java script to find client timezone offset and send to a server to calculate clients timezone
Thanks for your reply . I have get the time offset from the javascript as -330 . How I need to manipulate with date which I have in US date format. can you please help me
If possible send me the sample code
I am not aware how to manipulate date with the offset in java. can you help me
|
 |
josuva moorthy
Greenhorn
Joined: Apr 05, 2010
Posts: 11
|
|
Thanks for the reply .The first part of the code which help me how to use the locale .I am checking a code to get the timeOffset from the javascript (client Side )
read from the server side and change the date while displaying .
Thanks in advance
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
|
Be sure that you have a fallback default for cases when the user has JavaScript disabled.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: How to get current date based on time zone or locale, or user preference?
|
|
|