SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm");
TimeZone tz1 = TimeZone.getTimeZone("America/Los_Angeles");
TimeZone tz2 = TimeZone.getTimeZone("Asia/Karachi");

Date now=new Date();

//time in LA
sdf.setTimeZone(tz1);
System.out.println("Time in LA: "+sdf.format(now));

//time in LA
sdf.setTimeZone(tz2);
System.out.println("Time in Karachi: "+sdf.format(now));

has the following output:

Time in LA: 2004-08-19 03:23
Time in Karachi: 2004-08-19 15:23



Viral_Thakkar wrote:

Could you please provide the code snippet of this..??

-----Original Message-----
From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Thursday, August 19, 2004 12:59 PM
To: Struts Users Mailing List
Subject: Re: [OT] Date Localization


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]












--
Jason Lea




Reply via email to