}
public Object newValueForDate(Object value) {
if(valueFactoryMethod() != null) {
if(!(value instanceof Date)) {
throw new JDBCAdaptorException(new StringBuilder().append(value).append(" of type ").append(value.getClass().getName()).append(" is not a valid Date type. You must use java.sql.Timestamp, java.sql.Date, or java.sql.Time").toString(), null);
}
Date date = (Date)value;
//Call the custom factory method
try {
if(valueFactoryClass() != null) {
Class<?> factoryClass = valueFactoryClass();
return valueFactoryMethod().invoke(factoryClass, date);
}
Class<?> c = _NSUtilities.classWithName(className());
return valueFactoryMethod().invoke(c, date);
} catch(IllegalAccessException e) {
throw NSForwardException._runtimeExceptionForThrowable(e);
} catch(IllegalArgumentException e) {
throw NSForwardException._runtimeExceptionForThrowable(e);
} catch(NoSuchMethodException e) {
throw NSForwardException._runtimeExceptionForThrowable(e);
} catch(InvocationTargetException e) {
throw NSForwardException._runtimeExceptionForThrowable(e);
}
} else {
if(value instanceof Timestamp) {
return new NSTimestamp((Timestamp)value);
}
if(value instanceof Date) {
Date temp = (Date)value;
return new NSTimestamp(temp.getTime());
} else {
throw new JDBCAdaptorException(new StringBuilder().append(value).append(" of type ").append(value.getClass().getName()).append(" is not a valid Date type. You must use java.sql.Timestamp, java.sql.Date, or java.sql.Time").toString(), null);
}
}
}