Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes calendar timezone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

calendar timezone

samantha clarkson
Ranch Hand

Joined: Sep 09, 2008
Posts: 56
Hello, i have a gregorian calendar, i apply a timezone, then i retrieve the date, but it's displayed in GMT timezone , what can i do for retrieving a date from a calendar with a specified timezone .
After, i have to use a jcalendar which display the time coresponding to the time zone of the server machine, what could i do to get a calendar displaying date/time coresponding to a server machine not the mine.

Code :
TimeZone tz = TimeZone.getTimeZone("America/Caracas");
System.out.println("TZ ID : "+tz.getID());
System.out.println("TZ display name : "+tz.getDisplayName());
GregorianCalendar c = new GregorianCalendar();
c.setTimeZone(tz);
System.out.println("c TZ ID : "+c.getTimeZone().getID());
System.out.println("c TZ display name : "+c.getTimeZone().getDisplayName());
System.out.println("c time : "+c.getTime().toString());

Output :
TZ ID : America/Caracas
TZ display name : Heure du Venezuela
c TZ ID : America/Caracas
c TZ display name : Heure du Venezuela
c time : Sun May 31 13:16:08 GMT 2009

Thanks .


farm rubbit hihihihihihi, be aware !!
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

This is a repeat of the question you already posted in in your other thread. Please stick to one thread, and if you feel the need to crosspost, at least let others know you are doing so, so as to avoid repeat answers.


Steve
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Locking this one.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calendar timezone