// Do nothing, this is the expected behavior.
}
// Test creating a DateValue.
try {
GregorianCalendar calendar = new GregorianCalendar(2009, 2, 15);
calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
Value v = ValueType.DATE.createValue(calendar);
assertTrue(v.getType() == ValueType.DATE);
DateValue dv = (DateValue) v;
assertEquals(dv.compareTo(new DateValue(calendar)), 0);
} catch (TypeMismatchException e) {
fail();
}
// Verify that an exception is thrown on type mismatch for DateValue.
try {
Value v = ValueType.DATE.createValue("abc");
fail();
} catch (TypeMismatchException e) {
// Do nothing, this is the expected behavior.
}
// Test creating a null DateValue.
try {
Value v = ValueType.DATE.createValue(null);
assertTrue(v.getType() == ValueType.DATE);
DateValue dv = (DateValue) v;
assertEquals(dv, DateValue.getNullValue());
} catch (TypeMismatchException e) {
// Do nothing, this is the expected behavior.
}
// Test creating a DateTimeValue.
try {
GregorianCalendar calendar = new GregorianCalendar(2009, 2, 15, 12, 30, 14);
calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
Value v = ValueType.DATETIME.createValue(calendar);
assertTrue(v.getType() == ValueType.DATETIME);
DateTimeValue dtv = (DateTimeValue) v;
assertEquals(dtv.compareTo(new DateTimeValue(calendar)), 0);
} catch (TypeMismatchException e) {
fail();
}
// Verify that an exception is thrown on type mismatch for DateTimeValue.
try {
Value v = ValueType.DATETIME.createValue("abc");
fail();
} catch (TypeMismatchException e) {
// Do nothing, this is the expected behavior.
}
// Test creating a null DateTimeValue.
try {
Value v = ValueType.DATETIME.createValue(null);
assertTrue(v.getType() == ValueType.DATETIME);
DateTimeValue dtv = (DateTimeValue) v;
assertEquals(dtv, DateTimeValue.getNullValue());
} catch (TypeMismatchException e) {
// Do nothing, this is the expected behavior.
}
// Test creating a TimeOfDayValue.
try {
GregorianCalendar calendar = new GregorianCalendar(2009, 2, 15, 12, 30, 14);
calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
Value v = ValueType.TIMEOFDAY.createValue(calendar);
assertTrue(v.getType() == ValueType.TIMEOFDAY);
TimeOfDayValue todv = (TimeOfDayValue) v;
assertEquals(todv.compareTo(new TimeOfDayValue(calendar)), 0);
} catch (TypeMismatchException e) {