EdmTimeOfDay extends SingletonPrimitiveType { public static EdmTimeOfDay getInstance() { return INSTANCE; }  static EdmTimeOfDay getInstance(); @Override Class<?> getDefaultType();  }
@Test public void valueToString() throws Exception { Calendar dateTime = Calendar.getInstance(); dateTime.clear(); setTimeZone(dateTime, "GMT+11:30"); dateTime.set(1, 2, 3, 4, 5, 6); assertEquals("04:05:06", instance.valueToString(dateTime, null, null, null, null, null)); dateTime.add(Calendar.MILLISECOND, 42); assertEquals("04:05:06.042", instance.valueToString(dateTime, null, null, null, null, null)); assertEquals("04:05:06.042", instance.valueToString(dateTime, null, null, 3, null, null)); assertEquals("04:05:06.042", instance.valueToString(dateTime, null, null, 4, null, null)); Calendar dateTime2 = Calendar.getInstance(); dateTime2.clear(); setTimeZone(dateTime, TimeZone.getDefault()); dateTime2.set(Calendar.HOUR, 5); dateTime2.set(Calendar.MINUTE, 59); dateTime2.set(Calendar.SECOND, 23); final java.sql.Time time = new java.sql.Time(dateTime2.getTimeInMillis()); assertEquals("05:59:23", instance.valueToString(time, null, null, null, null, null)); assertEquals("05:59:23", instance.valueToString(dateTime2.getTimeInMillis(), null, null, null, null, null)); expectTypeErrorInValueToString(instance, 0); }
@Test public void valueOfString() throws Exception { Calendar dateTime = Calendar.getInstance(); dateTime.clear(); assertEqualCalendar(dateTime, instance.valueOfString("00:00", null, null, null, null, null, Calendar.class)); assertEqualCalendar(dateTime, instance.valueOfString("00:00:00", null, null, null, null, null, Calendar.class)); assertEqualCalendar(dateTime, instance.valueOfString("00:00:00.000000000", null, null, null, null, null, Calendar.class)); final Time timeValue = instance.valueOfString("00:00:00.999", null, null, 3, null, null, Time.class); assertEquals(dateTime.getTimeInMillis(), timeValue.getTime()); dateTime.set(Calendar.MILLISECOND, 999); assertEqualCalendar(dateTime, instance.valueOfString("00:00:00.999", null, null, 3, null, null, Calendar.class)); assertEqualCalendar(dateTime, instance.valueOfString("00:00:00.999", null, null, 3, null, null, Calendar.class)); assertEquals(Long.valueOf(dateTime.getTimeInMillis()), instance.valueOfString("00:00:00.999", null, null, 3, null, null, Long.class)); final Timestamp timestamp = instance.valueOfString("00:00:00.999888777", null, null, 9, null, null, Timestamp.class); assertEquals(dateTime.getTimeInMillis(), timestamp.getTime()); assertEquals(999888777, timestamp.getNanos()); expectContentErrorInValueOfString(instance, "24:32:02"); expectContentErrorInValueOfString(instance, "011:12:13"); expectContentErrorInValueOfString(instance, "11:12:13:14"); expectContentErrorInValueOfString(instance, "111213"); expectContentErrorInValueOfString(instance, "1:2:3"); expectContentErrorInValueOfString(instance, "11:12:13.0.1"); expectContentErrorInValueOfString(instance, "11:12:13.0000000000000"); expectTypeErrorInValueOfString(instance, "11:12:13"); }