I have one Calendar object which is as per the user’s time zone which may be PST etc, now i want to convert the same to GMT and retain the time i.e. is the calendar initially was set @ 00:00:00 at PST it should be converted to 08:00:00 after the conversion taking into consideration the time/date difference . Can someone provide me some help on this.
Appreciate the help in advance.
Thanks,
Vaibhav
Just create a new Calendar in GMT, set the time in that calendar to the same as the original calendar, and you’re done:
That should be fine, as the
getTime()call returns the instant in time (i.e. ajava.util.Datewith no associated time zone).As ever though, if you’re doing any significant amount of date/time work in Java you should strongly consider using Joda Time instead.