db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1070948 - in /db/derby/code/branches/10.6: ./ java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java
Date Tue, 15 Feb 2011 15:59:45 GMT
Author: mikem
Date: Tue Feb 15 15:59:44 2011
New Revision: 1070948

URL: http://svn.apache.org/viewvc?rev=1070948&view=rev
Log:
DERBY-4626: Timestamp truncated when converted to string with explicit calendar

backport change #999485 from trunk to 10.6 branch.

Added a test case. The bug was fixed as part of DERBY-4625.


Modified:
    db/derby/code/branches/10.6/   (props changed)
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java

Propchange: db/derby/code/branches/10.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 15 15:59:44 2011
@@ -1,2 +1,2 @@
-/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964039,964115,964402,965647,967304,980089,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,1002291,1002682,1002853,1021426,1025795,1028716,1030043,1033485,1033864,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250
+/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964039,964115,964402,965647,967304,980089,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,999485,1002291,1002682,1002853,1021426,1025795,1028716,1030043,1033485,1033864,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250
 /db/derby/docs/trunk:954344

Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java?rev=1070948&r1=1070947&r2=1070948&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java
Tue Feb 15 15:59:44 2011
@@ -30,6 +30,7 @@ import java.sql.Statement;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.Calendar;
+import java.util.TimeZone;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -915,6 +916,35 @@ public final class DateTimeTest extends 
     }
 
     /**
+     * Test that conversion from timestamp to string is correct when a
+     * calendar is specified. Specifically, verify that the full nanosecond
+     * resolution is used and that the converted timestamp is not rounded to
+     * microsecond resolution. Regression test case for DERBY-4626.
+     */
+    public void testConvertToStringWithCalendar() throws SQLException {
+        PreparedStatement ps =
+                prepareStatement("values cast(? as varchar(29))");
+
+        // Generate a timestamp representing 2010-09-01 20:31:40.123456789 GMT
+        Timestamp ts = new Timestamp(1283373100000L);
+        ts.setNanos(123456789);
+
+        // Array of (timezone, timestamp string) pairs representing a timezone
+        // with which to test and the expected timestamp string produced.
+        String[][] testData = {
+            { "GMT", "2010-09-01 20:31:40.123456789" },
+            { "Europe/Oslo", "2010-09-01 22:31:40.123456789" },
+        };
+
+        for (int i = 0; i < testData.length; i++) {
+            Calendar cal = Calendar.getInstance(
+                    TimeZone.getTimeZone(testData[i][0]));
+            ps.setTimestamp(1, ts, cal);
+            JDBC.assertSingleValueResultSet(ps.executeQuery(), testData[i][1]);
+        }
+    }
+
+    /**
      * Regression test case for DERBY-4621, which caused the conversion of
      * timestamp and time values to varchar to generate wrong results when
      * a Calendar object was supplied.



Mime
View raw message