EdmDateTimeOffset extends SingletonPrimitiveType { public static EdmDateTimeOffset getInstance() { return INSTANCE; }  static EdmDateTimeOffset getInstance(); @Override Class<?> getDefaultType();  }
@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)); }
@Test public void valueOfStringToCalendar() throws Exception { Calendar dateTime = Calendar.getInstance(); dateTime.clear(); setTimeZone(dateTime, "GMT"); dateTime.set(2012, 1, 29, 1, 2, 3); assertEqualCalendar(dateTime, instance.valueOfString("2012-02-29T01:02:03Z", null, null, null, null, null, Calendar.class)); assertEqualCalendar(dateTime, instance.valueOfString("2012-02-29T01:02:03", null, null, null, null, null, Calendar.class)); dateTime.clear(); setTimeZone(dateTime, "GMT-01:30"); dateTime.set(2012, 1, 29, 1, 2, 3); assertEquals(dateTime.getTime(), instance.valueOfString("2012-02-29T01:02:03-01:30", null, null, null, null, null, Date.class)); dateTime.clear(); setTimeZone(dateTime, "GMT+11:00"); dateTime.set(2012, 1, 29, 1, 2, 3); assertEqualCalendar(dateTime, instance.valueOfString("2012-02-29T01:02:03+11:00", null, null, null, null, null, Calendar.class)); dateTime.add(Calendar.MILLISECOND, 7); assertEqualCalendar(dateTime, instance.valueOfString("2012-02-29T01:02:03.007+11:00", null, null, 3, null, null, Calendar.class)); }
@Test public void valueOfStringToLong() throws Exception { Calendar dateTime = Calendar.getInstance(); dateTime.clear(); setTimeZone(dateTime, "GMT"); dateTime.set(2012, 1, 29, 1, 2, 3); assertEquals(Long.valueOf(dateTime.getTimeInMillis()), instance.valueOfString("2012-02-29T01:02:03+00:00", null, null, null, null, null, Long.class)); assertEquals(Long.valueOf(120000L), instance.valueOfString("1970-01-01T00:02Z", null, null, null, null, null, Long.class)); assertEquals(Long.valueOf(120000L), instance.valueOfString("1970-01-01T00:02", null, null, null, null, null, Long.class)); assertEquals(Long.valueOf(12L), instance.valueOfString("1970-01-01T00:00:00.012", null, null, 3, null, null, Long.class)); assertEquals(Long.valueOf(120L), instance.valueOfString("1970-01-01T00:00:00.12", null, null, 2, null, null, Long.class)); }