| Author |
settimezone on gregorian calendar doesn't work !!
|
samantha clarkson
Ranch Hand
Joined: Sep 09, 2008
Posts: 48
|
|
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.
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: 3032
|
|
The problem isn't that the Calendar's TimeZone isn't working. It is that you are printing the results in your computer's local time zone. You should use a DateFormatter to make sure the date is displayed in the same time zone the Calendar is maintained in:
|
Steve
|
 |
 |
|
|
subject: settimezone on gregorian calendar doesn't work !!
|
|
|