harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r554597 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/GregorianCalendar.java test/api/common/tests/api/java/util/GregorianCalendarTest.java
Date Mon, 09 Jul 2007 10:31:42 GMT
Author: tonywu
Date: Mon Jul  9 03:31:42 2007
New Revision: 554597

URL: http://svn.apache.org/viewvc?view=rev&rev=554597
Log:
Fix HARMONY-4372 ([classlib][luni] GregorianCalendar.roll() works incorrectly around end of
year if MinimalDaysInFirstWeek is 4)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/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?view=diff&rev=554597&r1=554596&r2=554597
==============================================================================
--- 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
Mon Jul  9 03:31:42 2007
@@ -1152,7 +1152,7 @@
                 int newWeek = mod(fields[field] - 1 + value, maxWeeks) + 1;
                 if (newWeek == maxWeeks) {
                     if (fields[day] + (newWeek - fields[field]) * 7 > days) {
-                        set(day, days);
+                        set(field, 1);
                     } else {
                         set(field, newWeek);
                     }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java?view=diff&rev=554597&r1=554596&r2=554597
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/tests/api/java/util/GregorianCalendarTest.java
Mon Jul  9 03:31:42 2007
@@ -561,11 +561,21 @@
 
 		cal.set(2004, Calendar.DECEMBER, 31, 5, 0, 0);
 		cal.roll(Calendar.WEEK_OF_YEAR, true);
-		assertTrue("Wrong year: " + cal.getTime(),
-				cal.get(Calendar.YEAR) == 2004);
-		assertTrue("Wrong month: " + cal.getTime(),
-				cal.get(Calendar.MONTH) == Calendar.JANUARY);
-		assertTrue("Wrong date: " + cal.getTime(), cal.get(Calendar.DATE) == 9);
+        assertEquals("Wrong year: " + cal.getTime(), 2004, cal
+                .get(Calendar.YEAR));
+        assertEquals("Wrong month: " + cal.getTime(), Calendar.JANUARY, cal
+                .get(Calendar.MONTH));
+        assertEquals("Wrong date: " + cal.getTime(), 9, cal.get(Calendar.DATE));
+
+        // Regression for HARMONY-4372
+        cal.set(1994, 11, 30, 5, 0, 0);
+        cal.setMinimalDaysInFirstWeek(4);
+        cal.roll(Calendar.WEEK_OF_YEAR, true);
+        assertEquals("Wrong year: " + cal.getTime(), 1994, cal
+                .get(Calendar.YEAR));
+        assertEquals("Wrong month: " + cal.getTime(), Calendar.JANUARY, cal
+                .get(Calendar.MONTH));
+        assertEquals("Wrong date: " + cal.getTime(), 7, cal.get(Calendar.DATE));
 	}
 
 	/**



Mime
View raw message