* @throws Exception If the test failes.
*/
public void testParse() throws Exception {
Calendar cal = Calendar.getInstance();
ISO8601DateTimeFormat formatter = new ISO8601DateTimeFormat();
// east
Date parsedDate = formatter.parse("1970-01-01T01:00:00+01:00");
cal.setTime(parsedDate);
cal.setTimeZone(TimeZone.getTimeZone("GMT+01"));
assertEquals(1970, cal.get(Calendar.YEAR));
assertEquals(Calendar.JANUARY, cal.get(Calendar.MONTH));
assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(1, cal.get(Calendar.HOUR_OF_DAY));
assertEquals(0, cal.get(Calendar.MINUTE));
assertEquals(0, cal.get(Calendar.SECOND));
// west
parsedDate = formatter.parse("1969-12-31T19:00:02-05:00");
cal.setTime(parsedDate);
cal.setTimeZone(TimeZone.getTimeZone("GMT-05"));
assertEquals(1969, cal.get(Calendar.YEAR));
assertEquals(Calendar.DECEMBER, cal.get(Calendar.MONTH));
assertEquals(31, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(19, cal.get(Calendar.HOUR_OF_DAY));
assertEquals(0, cal.get(Calendar.MINUTE));
assertEquals(2, cal.get(Calendar.SECOND));
// GMT
parsedDate = formatter.parse("2003-03-18T10:30:02Z");
cal.setTime(parsedDate);
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
assertEquals(2003, cal.get(Calendar.YEAR));
assertEquals(Calendar.MARCH, cal.get(Calendar.MONTH));
assertEquals(18, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(10, cal.get(Calendar.HOUR_OF_DAY));
assertEquals(30, cal.get(Calendar.MINUTE));
assertEquals(2, cal.get(Calendar.SECOND));
// default TZ
parsedDate = formatter.parse("1999-07-28T19:27:02");
cal.setTime(parsedDate);
cal.setTimeZone(TimeZone.getDefault());
assertEquals(1999, cal.get(Calendar.YEAR));
assertEquals(Calendar.JULY, cal.get(Calendar.MONTH));
assertEquals(28, cal.get(Calendar.DAY_OF_MONTH));