harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r426427 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/GregorianCalendar.java test/java/tests/api/java/util/GregorianCalendarTest.java
Date Fri, 28 Jul 2006 08:10:16 GMT
Author: pyang
Date: Fri Jul 28 01:10:15 2006
New Revision: 426427

URL: http://svn.apache.org/viewvc?rev=426427&view=rev
Log:
Fix for HARMONY-998 (java.util.Calendar: large hours, minutes and seconds are handled incorrectly)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java?rev=426427&r1=426426&r2=426427&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/GregorianCalendar.java
Fri Jul 28 01:10:15 2006
@@ -586,7 +586,7 @@
 		}
 
 		long timeVal;
-		int hour = 0;
+		long hour = 0;
 		if (isSet[HOUR_OF_DAY] && lastTimeFieldSet != HOUR) {
             hour = fields[HOUR_OF_DAY];
         } else if (isSet[HOUR]) {
@@ -595,10 +595,10 @@
 		timeVal = hour * 3600000;
 
 		if (isSet[MINUTE]) {
-            timeVal += fields[MINUTE] * 60000;
+            timeVal += ((long)fields[MINUTE]) * 60000;
         }
 		if (isSet[SECOND]) {
-            timeVal += fields[SECOND] * 1000;
+            timeVal += ((long)fields[SECOND]) * 1000;
         }
 		if (isSet[MILLISECOND]) {
             timeVal += fields[MILLISECOND];

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java?rev=426427&r1=426426&r2=426427&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/GregorianCalendarTest.java
Fri Jul 28 01:10:15 2006
@@ -559,6 +559,15 @@
         gCalend.set(Calendar.MILLISECOND, 0);//changes nothing
         assertEquals("After", dayOfMonth, gCalend.get(Calendar.DAY_OF_MONTH));
     }
+    
+    /**
+     * @tests GregorianCalendar#GregorianCalendar() 
+     */
+    public void testConstructorMaxvalue(){
+        Calendar cal = new GregorianCalendar();
+        cal.set(1900, 0, 0, 0, Integer.MAX_VALUE);
+        assertTrue(cal.getTime().getTime()>0); 
+    }
 
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method



Mime
View raw message