Time event in Java is stored as the number of milliseconds between this event and January 1, 1970, 00:00:00 GMT (e.g. as if it happened in London)
So whenever we talk date and time in Java, as represented by java.util.Date or java.util.Calendar, we always talk about absolute number, regardless of timezone.
Time zone only makes sense when we try to output date/time as string. On top of my head I can recall two ways of doing it:
- use Calendar, set time zone, use get(Calendar.XXX) method to get individual date/time components in time zone you want
- use SimpleDateTimeFormat, set time zone, format the whole date/time into single string in time zone you want
There is really no such thing as "time zone conversion" in Java, but there is time zone specific formatting.
However, if you want to make things really confusing, you can add the "correction" to your calendar time value so that it will return field values as if it was in PST timezone:
private Calendar getPSTTime(Calendar utcTime)
{
TimeZone pstZ = TimeZone.getTimeZone("America/Los_Angeles");
long offset = pstZ.getOffset(utcTime.getTime());
Calendar pacificTime = Calendar.getInstance();
pacificTime.setTimeInMillis(utcTime.getTimeInMillis()-offset);
return pacificTime;
}