aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Display date and time in users Timezone? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Display date and time in users Timezone?" Watch "Display date and time in users Timezone?" New topic
Author

Display date and time in users Timezone?

hasan khan
Ranch Hand

Joined: Aug 04, 2003
Posts: 222

how do i display date and time to the user in his timezone and locale.
if possible please provide an example. thanks in advance.
Abhinay Verma
Greenhorn

Joined: Dec 13, 2004
Posts: 24
You can use DateFormat class. Refer to the Code below


This code gave the following output
13 April 2005 16:53:46 GMT+05:30 //Locale was UK
April 13, 2005 4:54:56 PM GMT+05:30 //Locale was US
13 aprile 2005 16.56.29 GMT+05:30 //Locale was ITALY
13 avril 2005 16:59:55 GMT+05:30 //Locale was FRENCH

Hope this helps.
hasan khan
Ranch Hand

Joined: Aug 04, 2003
Posts: 222

Thanks Abhinay,
my question was "how display date and time to the user in his timezone and locale."

and i got the answer for locale but not for timezone.

for e.g.

my web server is in india. right now time is 17:00.
if some one from UK visit my site he should not get 17:00 in his browser but he should get (17 - 4.30) i.e 12:30

please help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display date and time in users Timezone?