Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.6
-
None
-
None
-
Operating System: other
Platform: Other
-
30520
Description
The present implementation of SqlDateConverter.convert() has three cases to
gerenarate new object from value parameter: If value was null, if value was a
java.sql.Date instance and if value was another class instance. Above a piece
of code:
// If value was null
if (value instanceof Date) {
return (value);
}
// If value was not a java.sql.Date instance
My propose is include 2 cases, between case of java.sql.Date instance and other
class instance. This cases will what to do if value was a java.util.Date
instance or a Calendar instance. In first case, it will be returned a new
instance of java.sql.Date from value.getTime() value. In second case , it will
be returned a new instance of java.sql.Date from value.getTimeInMillis() value.
Like this:
// If value was null
if (value instanceof Date) {
return (value);
}
if (value instanceof java.util.Date) {
return new Date(((java.util.Date)value).getTime());
}
if (value instanceof Calendar) {
return new Date(((Calendar)value).getTimeInMillis());
}
// If value was not a java.sql.Date instance
IMHO, with this the convert method could be more accurated.
Something similar could be done in SqlTimeConverter and SqlTimestampConverter.