db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r373385 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils: model/Column.java platform/DefaultValueHelper.java
Date Sun, 29 Jan 2006 23:09:20 GMT
Author: tomdz
Date: Sun Jan 29 15:09:16 2006
New Revision: 373385

URL: http://svn.apache.org/viewcvs?rev=373385&view=rev
Log:
Enhanced handling of DATE/TIME/TIMESTAMP default values

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Column.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DefaultValueHelper.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Column.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Column.java?rev=373385&r1=373384&r2=373385&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Column.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Column.java Sun Jan 29 15:09:16 2006
@@ -439,6 +439,8 @@
             }
             catch (NumberFormatException ex)
             {}
+            catch (IllegalArgumentException ex)
+            {}
         }
         return _defaultValue;
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DefaultValueHelper.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DefaultValueHelper.java?rev=373385&r1=373384&r2=373385&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DefaultValueHelper.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DefaultValueHelper.java Sun Jan
29 15:09:16 2006
@@ -16,6 +16,9 @@
  * limitations under the License.
  */
 
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
 import java.sql.Types;
 
 import org.apache.commons.beanutils.ConversionException;
@@ -51,6 +54,31 @@
                 case Types.BIT:
                     result = convertBoolean(defaultValue, targetTypeCode).toString();
                     break;
+                case Types.DATE:
+                	if (targetTypeCode == Types.TIMESTAMP)
+                	{
+                		try
+                		{
+                			Date date = Date.valueOf(result);
+
+                			return new Timestamp(date.getTime()).toString();
+                		}
+                		catch (IllegalArgumentException ex)
+                		{}
+                	}
+                	break;
+                case Types.TIME:
+                	if (targetTypeCode == Types.TIMESTAMP)
+                	{
+                		try
+                		{
+                			Time time = Time.valueOf(result);
+
+                			return new Timestamp(time.getTime()).toString();
+                		}
+                		catch (IllegalArgumentException ex)
+                		{}
+                	}
                 default:
                     if (Jdbc3Utils.supportsJava14JdbcTypes() &&
                         (originalTypeCode == Jdbc3Utils.determineBooleanTypeCode()))



Mime
View raw message