You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Viral_Thakkar <Vi...@infosys.com> on 2004/08/19 08:24:17 UTC
[OT] Date Localization
Hi All,
I have a Date stored in GMT format in database. Now I need to display
this date to user depending on his/her LOCALE. I found SimpleDateFormat
and few other classes to convert the Date Format, but I am not able to
find how to change the Date value as per user locale.
Example:
Date in database : 19 August 2004 6:30 PM
Date for User from India should be : 19 August 2004 1:00 PM
How to achieve this .???
TIA,
Viral
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [OT] Date Localization
Posted by Shinobu Kawai <sh...@ieee.org>.
Hi Viral,
> I have a Date stored in GMT format in database. Now I need to display
> this date to user depending on his/her LOCALE. I found SimpleDateFormat
> and few other classes to convert the Date Format, but I am not able to
> find how to change the Date value as per user locale.
>
> Example:
> Date in database : 19 August 2004 6:30 PM
>
> Date for User from India should be : 19 August 2004 1:00 PM
What you need is not a java.util.Locale, but a java.util.TimeZone. As
for that, I have no information that you can acquire the client's
TimeZone via the Servlet API. I can think of two solutions at the
moment:
1. map users to time zones
2. map locales to time zones
Best regards,
-- Shinobu Kawai
--
Shinobu Kawai <shinobu@ieee.org, shinobu@computer.org>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [OT] Date Localization
Posted by Jason Lea <ja...@kumachan.net.nz>.
The SimpleDateFormat has a setTimeZone() method (coming from DateFormat).
The locale doesn't have timezone information, locale is about language
and countries. Countries may have several different timezones so there
is no accurate way to map them to timezones. I normally allow users to
pick their own timezone and store that in some preference settings for
them. Then display date/time using that timezone.
Viral_Thakkar wrote:
>Hi All,
>
>I have a Date stored in GMT format in database. Now I need to display
>this date to user depending on his/her LOCALE. I found SimpleDateFormat
>and few other classes to convert the Date Format, but I am not able to
>find how to change the Date value as per user locale.
>
>Example:
>Date in database : 19 August 2004 6:30 PM
>
>Date for User from India should be : 19 August 2004 1:00 PM
>
>How to achieve this .???
>
>TIA,
>Viral
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
--
Jason Lea
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org