// If the given value is null, return a null date value.
if (value.isNull()) {
return DateValue.getNullValue();
}
DateValue dateValue;
switch(value.getType()) {
case DATE:
dateValue = (DateValue) value;
break;
case DATETIME:
dateValue = new DateValue((GregorianCalendar)
(((DateTimeValue) value).getObjectToFormat()));
break;
case NUMBER:
date = new Date((long) ((NumberValue) value).getValue());
gc.setTime(date);
dateValue = new DateValue(gc);
break;
default:// Should never get here.
throw new RuntimeException("Value type was not found: " + value.getType());
}
return dateValue;