commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r470904 - /jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/BeanProcessor.java
Date Fri, 03 Nov 2006 17:03:07 GMT
Author: bayard
Date: Fri Nov  3 09:03:06 2006
New Revision: 470904

URL: http://svn.apache.org/viewvc?view=rev&rev=470904
Log:
Enabling the bean handlers to support java.sql.Date, Time and Timestamp. #DBUTILS-1. 

Modified:
    jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/BeanProcessor.java

Modified: jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/BeanProcessor.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/BeanProcessor.java?view=diff&rev=470904&r1=470903&r2=470904
==============================================================================
--- jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/BeanProcessor.java
(original)
+++ jakarta/commons/proper/dbutils/trunk/src/java/org/apache/commons/dbutils/BeanProcessor.java
Fri Nov  3 09:03:06 2006
@@ -222,6 +222,21 @@
 
         Class[] params = setter.getParameterTypes();
         try {
+            // convert types for some popular ones
+            if (value != null) {
+                if (value instanceof java.util.Date) {
+                    if (params[0].getName().equals("java.sql.Date")) {
+                        value = new java.sql.Date(((java.util.Date) value).getTime());
+                    } else
+                    if (params[0].getName().equals("java.sql.Time")) {
+                        value = new java.sql.Time(((java.util.Date) value).getTime());
+                    } else
+                    if (params[0].getName().equals("java.sql.Timestamp")) {
+                        value = new java.sql.Timestamp(((java.util.Date) value).getTime());
+                    }
+                }
+            }
+
             // Don't call setter if the value object isn't the right type 
             if (this.isCompatibleType(value, params[0])) {
                 setter.invoke(target, new Object[] { value });



---------------------------------------------------------------------
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