harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Ellison (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-5195) [classlib][luni] java.util.Calendar doesn't recalculate fields after timeZone changing.
Date Mon, 26 Nov 2007 20:59:43 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-5195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12545602
] 

Tim Ellison commented on HARMONY-5195:
--------------------------------------

I rebuilt the code from scratch, and got the same error.

Here's the changes that I'm testing with...




Index: src/main/java/java/util/Calendar.java
===================================================================
--- src/main/java/java/util/Calendar.java	(revision 598357)
+++ src/main/java/java/util/Calendar.java	(working copy)
@@ -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;
 	}
 
 	/**
Index: src/test/api/common/tests/api/java/util/GregorianCalendarTest.java
===================================================================
--- src/test/api/common/tests/api/java/util/GregorianCalendarTest.java	(revision 598357)
+++ src/test/api/common/tests/api/java/util/GregorianCalendarTest.java	(working copy)
@@ -140,11 +140,23 @@
 		// value
 		assertTrue("Incorrect calendar returned",
 				gc1.get(Calendar.HOUR) == ((gc2.get(Calendar.HOUR) + 1) % 12));
-        
+
         // Regression test for HARMONY-2961
         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);
+        c1.setTimeZone(new SimpleTimeZone(60000, "ONE MINUTE"));
+        String res = c1.get(Calendar.HOUR)+":"+c1.get(Calendar.MINUTE)+":"+c1.get(Calendar.SECOND);
+        assertEquals("3:35:16",res);
 	}
 
 	/**


> [classlib][luni] java.util.Calendar doesn't recalculate fields after timeZone changing.
> ---------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5195
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5195
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Sergey Kuksenko
>            Assignee: Tim Ellison
>            Priority: Minor
>         Attachments: calendar.patch, Greg_calendar_test.patch, Greg_calendar_test1.patch
>
>
> java.util.Calendar doesn't recalculate fields after timeZone changing.
> For example:
>            Calendar c1 = new GregorianCalendar(1999, Calendar.JUNE, 2, 15, 34, 16);
>            c1.setTimeZone(new SimpleTimeZone(60000, "ONE MINUTE"));
>            String res = c1.get(Calendar.HOUR)+":"+c1.get(Calendar.MINUTE)+":"+c1.get(Calendar.SECOND);
> After that Harmony returns "3:34:16" instead of "11:35:16" as RI does.
> Patch for unit teste for regression testing is done.
> Patch for the issue is done (also the patch slightly improve performance when calendar
already parsed time).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message