Dziwny problem ze strefą czasową, kalendarzem i SimpleDateFormat

Rozważmy następujący kod:

SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy", Locale.US);
long start = sdf.parse("10:30:00 30/09/2009").getTime();
long end = sdf.parse("10:30:00 30/10/2009").getTime();

Calendar c = Calendar.getInstance(Locale.US);
c.setTimeInMillis(start);
System.out.println("Start = " + c.getTime());
c.setTimeInMillis(end);
System.out.println("  End = " + c.getTime());

Podczas uruchamiania tego fragmentu kodu mam następujące dane wyjściowe:

Start = Wed Sep 30 10:30:00 CEST 2009
  End = Fri Oct 30 10:30:00 CET 2009

Dlaczego otrzymuję inną strefę czasową?

Zauważ, że jeśli ustawię pierwszą datę w sierpniu i drugą we wrześniu, wyjście wyświetli tę samą strefę czasową w obu przypadkach:

long start = sdf.parse("10:30:00 30/08/2009").getTime();
long end = sdf.parse("10:30:00 30/09/2009").getTime();

wyświetli się:

Start = Sun Aug 30 10:30:00 CEST 2009
  End = Wed Sep 30 10:30:00 CEST 2009

Używam Java 1.6.0_14

questionAnswers(3)

yourAnswerToTheQuestion