harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lvj...@apache.org
Subject svn commit: r648936 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/GregorianCalendar.java test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java
Date Thu, 17 Apr 2008 03:01:02 GMT
Author: lvjing
Date: Wed Apr 16 20:00:58 2008
New Revision: 648936

URL: http://svn.apache.org/viewvc?rev=648936&view=rev
Log:
Apply patch for HARMONY-2422,[classlib][luni] Can not set negative value to java.util.GregorianCalendar.ZONE_OFFSET

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java?rev=648936&r1=648935&r2=648936&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
Wed Apr 16 20:00:58 2008
@@ -446,7 +446,9 @@
     protected void computeFields() {
         int zoneOffset = getTimeZone().getRawOffset();
 
-        fields[ZONE_OFFSET] = zoneOffset;
+        if(!isSet[ZONE_OFFSET]) {
+            fields[ZONE_OFFSET] = zoneOffset;
+        }
 
         int millis = (int) (time % 86400000);
         int savedMillis = millis;

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java?rev=648936&r1=648935&r2=648936&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/GregorianCalendarTest.java
Wed Apr 16 20:00:58 2008
@@ -753,6 +753,15 @@
         assertEquals(0, gc.get(Calendar.SECOND));
         gc.set(1582, Calendar.OCTOBER, 14, 0, 0, 0);
         assertEquals(24, gc.get(Calendar.DAY_OF_MONTH));
+        
+        // Regression test for HARMONY-2422
+        gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+        gc.set(GregorianCalendar.ZONE_OFFSET, -1);
+        assertEquals(-1, gc.get(GregorianCalendar.ZONE_OFFSET));
+        gc.set(GregorianCalendar.ZONE_OFFSET, 1);
+        assertEquals(1, gc.get(GregorianCalendar.ZONE_OFFSET));
+        gc.set(GregorianCalendar.ZONE_OFFSET, 0);
+        assertEquals(0, gc.get(GregorianCalendar.ZONE_OFFSET));
     }
 
 	/**



Mime
View raw message