[
https://issues.apache.org/jira/browse/BEANUTILS-239?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Niall Pemberton resolved BEANUTILS-239.
---------------------------------------
Resolution: Fixed
Fix Version/s: 1.8.0
> [beanutils] Better implementation of SqlDateConverter.convert()
> ---------------------------------------------------------------
>
> Key: BEANUTILS-239
> URL: https://issues.apache.org/jira/browse/BEANUTILS-239
> Project: Commons BeanUtils
> Issue Type: Improvement
> Affects Versions: 1.6
> Environment: Operating System: other
> Platform: Other
> Reporter: Rafael U. C. Afonso
> Priority: Minor
> Fix For: 1.8.0
>
> 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.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]