commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vadim Gritsenko (JIRA)" <j...@apache.org>
Subject [jira] Commented: (BEANUTILS-239) [beanutils] Better implementation of SqlDateConverter.convert()
Date Sat, 02 Sep 2006 14:18:23 GMT
    [ http://issues.apache.org/jira/browse/BEANUTILS-239?page=comments#action_12432286 ] 
            
Vadim Gritsenko commented on BEANUTILS-239:
-------------------------------------------

Patch applied (revision 439601) to the trunk with modification. Calendar.getTimeInMillis()
has protected access in Java 1.3, used Calendar.getTime().getTime() instead. Added a test
case.

> [beanutils] Better implementation of SqlDateConverter.convert()
> ---------------------------------------------------------------
>
>                 Key: BEANUTILS-239
>                 URL: http://issues.apache.org/jira/browse/BEANUTILS-239
>             Project: Commons BeanUtils
>          Issue Type: Improvement
>    Affects Versions: 1.6 Release
>         Environment: Operating System: other
> Platform: Other
>            Reporter: Rafael U. C. Afonso
>            Priority: Minor
>         Attachments: SqlDateConverter.java, SqlTimeConverter.java, SqlTimestampConverter.java
>
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message