harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lian...@apache.org
Subject svn commit: r501757 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/GregorianCalendar.java test/java/tests/api/java/util/GregorianCalendarTest.java
Date Wed, 31 Jan 2007 07:50:41 GMT
Author: liangyx
Date: Tue Jan 30 23:50:40 2007
New Revision: 501757

URL: http://svn.apache.org/viewvc?view=rev&rev=501757
Log:
Apply patch for HARMONY-2947([classlib][luni]GregorianCalendar.getLeastMaximum(Calendar.WEEK_OF_YEAR)
always return 50)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/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=501757&r1=501756&r2=501757
==============================================================================
--- 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
Tue Jan 30 23:50:40 2007
@@ -43,8 +43,10 @@
      * Value for the AD era.
      */
     public static final int AD = 1;
+    
+    private static final long defaultGregorianCutover = -12219292800000l;
 
-    private long gregorianCutover = -12219292800000l;
+    private long gregorianCutover = defaultGregorianCutover;
 
     private transient int changeYear = 1582;
 
@@ -860,7 +862,7 @@
     @Override
     public int getActualMaximum(int field) {
         int value;
-        if ((value = getMaximum(field)) == getLeastMaximum(field)) {
+        if ((value = maximums[field]) == leastMaximums[field]) {
             return value;
         }
 
@@ -963,6 +965,16 @@
      */
     @Override
     public int getLeastMaximum(int field) {
+        // return value for WEEK_OF_YEAR should make corresponding changes when
+        // the gregorian change date have been reset.
+        if (gregorianCutover != defaultGregorianCutover
+                && field == WEEK_OF_YEAR) {
+            long currentTimeInMillis = time;
+            setTimeInMillis(gregorianCutover);
+            int actual = getActualMaximum(field);
+            setTimeInMillis(currentTimeInMillis);
+            return actual;
+        }
         return leastMaximums[field];
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java?view=diff&rev=501757&r1=501756&r2=501757
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
Tue Jan 30 23:50:40 2007
@@ -408,6 +408,14 @@
 		}
 		assertTrue("Wrong least max for " + result + " = " + values, result
 				.length() == 0);
+        
+        // Regression test for harmony-2947
+        Date date = new Date(Date.parse("Jan 1 00:00:01 GMT 2000"));
+        gc = new GregorianCalendar();
+        gc.setGregorianChange(date);
+        gc.setTime(date);
+        assertEquals(gc.getActualMaximum(Calendar.WEEK_OF_YEAR), gc
+                .getLeastMaximum(Calendar.WEEK_OF_YEAR));
 	}
 
 	/**



Mime
View raw message