db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r909999 - in /db/torque/village/trunk: src/java/com/workingdogs/village/Value.java xdocs/changes.xml
Date Sun, 14 Feb 2010 11:31:25 GMT
Author: seade
Date: Sun Feb 14 11:31:24 2010
New Revision: 909999

URL: http://svn.apache.org/viewvc?rev=909999&view=rev
Log:
Deal with situation arising in jre1.6.0_18 where an IllegalArgumentException is encountered
for dates with a single digit month or day of month.  Resolves TORQUE-133.

Reapplying patch to correct location.

Modified:
    db/torque/village/trunk/src/java/com/workingdogs/village/Value.java
    db/torque/village/trunk/xdocs/changes.xml

Modified: db/torque/village/trunk/src/java/com/workingdogs/village/Value.java
URL: http://svn.apache.org/viewvc/db/torque/village/trunk/src/java/com/workingdogs/village/Value.java?rev=909999&r1=909998&r2=909999&view=diff
==============================================================================
--- db/torque/village/trunk/src/java/com/workingdogs/village/Value.java (original)
+++ db/torque/village/trunk/src/java/com/workingdogs/village/Value.java Sun Feb 14 11:31:24
2010
@@ -1244,17 +1244,17 @@
             {
                 cal.setTime((Time) valueObject);
 
-                return java.sql.Date.valueOf(cal.get(Calendar.YEAR) + "-" + 
-                                            (cal.get(Calendar.MONTH) + 1) + "-"
-                                            + cal.get(Calendar.DAY_OF_MONTH));
+                return java.sql.Date.valueOf(cal.get(Calendar.YEAR) + "-"
+                        + leadingZero(cal.get(Calendar.MONTH) + 1) + "-"
+                        + leadingZero(cal.get(Calendar.DAY_OF_MONTH)));
             }
             else if (isUtilDate())
             {
                 cal.setTime((java.util.Date) valueObject);
 
-                return java.sql.Date.valueOf(cal.get(Calendar.YEAR) + "-" + 
-                                            (cal.get(Calendar.MONTH) + 1) + "-"
-                                            + cal.get(Calendar.DAY_OF_MONTH));
+                return java.sql.Date.valueOf(cal.get(Calendar.YEAR) + "-"
+                        + leadingZero(cal.get(Calendar.MONTH) + 1) + "-"
+                        + leadingZero(cal.get(Calendar.DAY_OF_MONTH)));
             }
             else if (isString())
             {
@@ -1311,17 +1311,17 @@
             {
                 cal.setTime((Time) valueObject);
 
-                return java.sql.Date.valueOf(cal.get(Calendar.YEAR) + "-" + 
-                                            (cal.get(Calendar.MONTH) + 1) + "-"
-                                            + cal.get(Calendar.DAY_OF_MONTH));
+                return java.sql.Date.valueOf(cal.get(Calendar.YEAR) + "-"
+                        + leadingZero(cal.get(Calendar.MONTH) + 1) + "-"
+                        + leadingZero(cal.get(Calendar.DAY_OF_MONTH)));
             }
             else if (isUtilDate())
             {
                 cal.setTime((java.util.Date) valueObject);
 
-                return java.sql.Date.valueOf(cal.get(Calendar.YEAR) + "-" + 
-                                            (cal.get(Calendar.MONTH) + 1) + "-"
-                                            + cal.get(Calendar.DAY_OF_MONTH));
+                return java.sql.Date.valueOf(cal.get(Calendar.YEAR) + "-"
+                        + leadingZero(cal.get(Calendar.MONTH) + 1) + "-"
+                        + leadingZero(cal.get(Calendar.DAY_OF_MONTH)));
             }
             else
             {
@@ -1522,4 +1522,15 @@
                 || value.equalsIgnoreCase("yes")
         || value.equalsIgnoreCase("y") || value.equals("1"));
     }
+
+    /**
+     * Convert an int to a two digit String with a leading zero where necessary.
+     *
+     * @param val The value to be converted.
+     * @return A two character String with leading zero.
+     */
+    private String leadingZero(int val)
+    {
+        return (val < 10 ? "0" : "") + val;
+    }
 }

Modified: db/torque/village/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/village/trunk/xdocs/changes.xml?rev=909999&r1=909998&r2=909999&view=diff
==============================================================================
--- db/torque/village/trunk/xdocs/changes.xml (original)
+++ db/torque/village/trunk/xdocs/changes.xml Sun Feb 14 11:31:24 2010
@@ -25,6 +25,11 @@
 
   <body>
   <release version="3.3.1-SNAPSHOT" date="in SVN">
+    <action type="fix" dev="seade" issue="TORQUE-133" due-to="Georg Marx">
+      Deal with situation arising in jre1.6.0_18 where an
+      IllegalArgumentException is encountered for dates with a single digit
+      month or day of month.
+    </action>
     <action type="fix" dev="tv">
       Fixed the infamous NPE when Oracle returns null for a blob.
     </action>



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


Mime
View raw message