CalendarHelper { public static String toString(Calendar cal) { StringBuilder buf = new StringBuilder(28); toString(cal, buf); return buf.toString(); } private  CalendarHelper(); static GregorianCalendar fromString(String datetime); static String toString(Calendar cal); static void toString(Calendar cal, StringBuilder buf);  }
@Test public void testToString1() { Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT+07:30")); cal.set(Calendar.YEAR, 2009); cal.set(Calendar.MONTH, 0); cal.set(Calendar.DATE, 2); cal.set(Calendar.HOUR_OF_DAY, 3); cal.set(Calendar.MINUTE, 4); cal.set(Calendar.SECOND, 5); cal.set(Calendar.MILLISECOND, 6); assertEquals("2009-01-02T03:04:05.006+07:30", CalendarHelper.toString(cal)); }
@Test public void testToString2() { Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT-06:00")); cal.set(Calendar.YEAR, 2008); cal.set(Calendar.MONTH, 11); cal.set(Calendar.DATE, 31); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); assertEquals("2008-12-31T23:59:59.999-06:00", CalendarHelper.toString(cal)); }
@Test public void testToString3() { Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); cal.set(Calendar.YEAR, 2008); cal.set(Calendar.MONTH, 0); cal.set(Calendar.DATE, 1); cal.set(Calendar.HOUR_OF_DAY, 1); cal.set(Calendar.MINUTE, 1); cal.set(Calendar.SECOND, 1); cal.set(Calendar.MILLISECOND, 1); assertEquals("2008-01-01T01:01:01.001Z", CalendarHelper.toString(cal)); }