You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/08/07 23:54:23 UTC
DO NOT REPLY [Bug 30520] New: -
[commons-beanutils]Better implementation of SqlDateConverter.convert()
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30520>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=30520
[commons-beanutils]Better implementation of SqlDateConverter.convert()
Summary: [commons-beanutils]Better implementation of
SqlDateConverter.convert()
Product: Commons
Version: 1.6 Final
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: Bean Utilities
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: r.u.c.afonso@uol.com.br
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.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org