Working with dates, times and timezones in
Java can be confusing.
One thing that you need to be aware of is that class java.util.Date does not store information about timezones. A java.util.Date is a kind of fancy wrapper that stores a number of milliseconds since January 1, 1970, 00:00:00 GMT. So in a way you can regard a java.util.Date as always being in the GMT timezone.
A Calendar does have a TimeZone property, but setting or modifying it does not convert the date and time that the calendar holds to a different timezone.
When you convert a Date to a
String by using a DateFormat object, then you can set the timezone on the DateFormat object, and it will convert your Date to a String that represents the date and time in that timezone. Likewise when you have a String that contains a Date and you use a DateFormat object to parse it. For example:
This prints out:
2006-11-28 15:45:12