if (value == null) {
if (this.useDefault) {
return (this.defaultValue);
}
throw new ConversionException("No value specified");
}
if (value instanceof Date) {
return (value);
} else if (value instanceof java.lang.String) {
String valueStr = (String) value;
// w3c DateParser defaults to 1970 for an empty string
if (valueStr.length() == 0) {
throw new ConversionException(
"Cannot convert an empty string to " + Date.class);
}
try {
return DateParser.parse(valueStr);
} catch (InvalidDateException ide) {
throw new ConversionException(ide);
}
}
if (this.useDefault) {
return (this.defaultValue);
}
throw new ConversionException("Cannot convert.");
}