SimpleDateFormat

Good to know: the format() function of the SimpleDateFormat class (and probably the DateFormat class as well) renders its date parameter to String in the default timezone available at the moment of the formatter object's creation.

The following example demonstrates it:
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Prague"));
Calendar cal = Calendar.getInstance();
SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
System.out.println("Default timezone: " + TimeZone.getDefault().toString());
System.out.println("formatter1: " + formatter1.format(cal.getTime()));
TimeZone.setDefault(TimeZone.getTimeZone("Etc/GMT"));
SimpleDateFormat formatter2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
System.out.println("Default timezone: " + TimeZone.getDefault().toString());
System.out.println("formatter1: " + formatter1.format(cal.getTime()));
System.out.println("formatter2: " + formatter2.format(cal.getTime()));

The output will be something like the following:
Default timezone: sun.util.calendar.ZoneInfo[id="Europe/Prague",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=141,lastRule=java.util.SimpleTimeZone[id=Europe/Prague,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]
formatter1: 2006-09-22 10:24:43 +0200
Default timezone: sun.util.calendar.ZoneInfo[id="Etc/GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]
formatter1: 2006-09-22 10:24:43 +0200
formatter2: 2006-09-22 08:24:43 +0000

This is interesting because ...
  1. It's not documented in the Java API.
  2. One cannot specify a TimeZone to be used at execution time of the format() function. Sad
  3. I think one could expect that the formatter prints the date in the timezone of the Date object itself and not the default timezone. Shock
Here's an excerpt from the source of the SimpleDateFormat class:
// The format object must be constructed using the symbols for this zone.
// However, the calendar should use the current default TimeZone.
// If this is not contained in the locale zone strings, then the zone
// will be formatted using generic GMT+/-H:MM nomenclature.
calendar = Calendar.getInstance(TimeZone.getDefault(), loc);

So you can define the Locale, but not the TimeZone. Sad