Java SimpleDateFormat analizuje wynik o jedną godzinę (i tak, ustawiam strefę czasową)
Zagadnij mi to: dlaczego ta prosta asercja JUnit kończy się niepowodzeniem?
public void testParseDate() throws ParseException {
final SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss z");
formatter.setTimeZone(UTC);
final Calendar c = new GregorianCalendar();
c.setTime(formatter.parse("2013-03-02 11:59:59 UTC"));
assertEquals(11, c.get(HOUR_OF_DAY));
}
Spodziewałbym się, że godzina będzie 11, ale według JUnit godzina dnia wynosi 12.
junit.framework.AssertionFailedError: expected:<11> but was:<12>
at junit.framework.Assert.fail(Assert.java:47)
... snip ...