Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Changing TimeZone for Calendar object doesnt change its time

user13162080Sep 13 2011 — edited Sep 14 2011
Hy, I have a Calendar object with I have set with a Date but I I want from this calendar with the Date set, set other timezone for this calendar and get the corresponding time(always gettting the correct time if is in daylightsavings) but I get the same time.

Calendar calendario = Calendar.getInstance
calendario.setTime(new Date());
System.out.println(calendario.getTime()); *// for example I get the 14:12:25 hours for GMT+01:00*
calendario.setTimeZone(TimeZone.getTimeZone("GMT+02:00")); *//change time zone using GMT*
System.out.println(calendario.getTime()); *// I get the same hour: 14:12:25*

Why? How to do it using GMT format?

Thanks

Edited by: user13162080 on 13-sep-2011 14:31

Edited by: user13162080 on 13-sep-2011 14:48
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 12 2011
Added on Sep 13 2011
6 comments
479 views