@Test
public void valueToStringFromCalendar() throws Exception {

  Calendar dateTime = Calendar.getInstance();
  dateTime.clear();
  setTimeZone(dateTime, "GMT");
  dateTime.set(2012, 1, 29, 1, 2, 3);
  assertEquals("2012-02-29T01:02:03Z", instance.valueToString(dateTime, null, null, null, null, null));
  assertEquals("2012-02-29T01:02:03Z", instance.valueToString(dateTime, null, null, 0, null, null));
  assertEquals("2012-02-29T01:02:03Z", instance.valueToString(dateTime, null, null, 5, null, null));
  setTimeZone(dateTime, "GMT-1:30");
  assertEquals("2012-02-28T23:32:03-01:30", instance.valueToString(dateTime, null, null, null, null, null));
  setTimeZone(dateTime, "GMT+11:00");
  assertEquals("2012-02-29T12:02:03+11:00", instance.valueToString(dateTime, null, null, null, null, null));
  dateTime.set(Calendar.MILLISECOND, 503);
  assertEquals("2012-02-29T12:02:03.503+11:00", instance.valueToString(dateTime, null, null, null, null, null));
  assertEquals("2012-02-29T12:02:03.503+11:00", instance.valueToString(dateTime, null, null, 3, null, null));
  dateTime.set(Calendar.MILLISECOND, 530);
  assertEquals("2012-02-29T12:02:03.53+11:00", instance.valueToString(dateTime, null, null, null, null, null));
  assertEquals("2012-02-29T12:02:03.53+11:00", instance.valueToString(dateTime, null, null, 3, null, null));
  dateTime.set(Calendar.MILLISECOND, 53);
  assertEquals("2012-02-29T12:02:03.053+11:00", instance.valueToString(dateTime, null, null, null, null, null));
  assertEquals("2012-02-29T12:02:03.053+11:00", instance.valueToString(dateTime, null, null, 3, null, null));
}