harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r598613 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/Calendar.java test/api/common/tests/api/java/util/GregorianCalendarTest.java
Date Tue, 27 Nov 2007 12:36:31 GMT
Author: tellison
Date: Tue Nov 27 04:36:29 2007
New Revision: 598613

URL: http://svn.apache.org/viewvc?rev=598613&view=rev
Log:
Apply patch HARMONY-5195 ([classlib][luni] java.util.Calendar doesn't recalculate fields after
timeZone changing.)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.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/Calendar.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java?rev=598613&r1=598612&r2=598613&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Calendar.java Tue
Nov 27 04:36:29 2007
@@ -725,10 +725,12 @@
 	 *            the time as the number of milliseconds since Jan. 1, 1970
 	 */
 	public void setTimeInMillis(long milliseconds) {
-		time = milliseconds;
+            if(!isTimeSet || !areFieldsSet || time!=milliseconds){	
+        	time = milliseconds;
 		isTimeSet = true;
 		areFieldsSet = false;
 		complete();
+	    }
 	}
 
 	/**
@@ -739,6 +741,7 @@
 	 */
 	public void setTimeZone(TimeZone timezone) {
 		zone = timezone;
+		areFieldsSet = false;
 	}
 
 	/**

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?rev=598613&r1=598612&r2=598613&view=diff
==============================================================================
--- 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
Tue Nov 27 04:36:29 2007
@@ -145,6 +145,19 @@
         SimpleTimeZone timezone = new SimpleTimeZone(-3600 * 24 * 1000 * 2,
                 "GMT");
         GregorianCalendar gc = new GregorianCalendar(timezone);
+
+	   // Regression test for HARMONY-5195
+           Calendar c1 = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
+           c1.set(Calendar.YEAR,1999);
+           c1.set(Calendar.MONTH,Calendar.JUNE);
+           c1.set(Calendar.DAY_OF_MONTH,2);
+           c1.set(Calendar.HOUR,15);
+           c1.set(Calendar.MINUTE,34);
+           c1.set(Calendar.SECOND,16);
+           assertEquals(34,c1.get(Calendar.MINUTE));
+           c1.setTimeZone(new SimpleTimeZone(60000, "ONE MINUTE"));
+           assertEquals(35,c1.get(Calendar.MINUTE));
+
 	}
 
 	/**



Mime
View raw message