You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/05/25 11:04:30 UTC
svn commit: r409336 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/java/util/GregorianCalendar.java
test/java/tests/api/java/util/GregorianCalendarTest.java
Author: smishura
Date: Thu May 25 02:04:28 2006
New Revision: 409336
URL: http://svn.apache.org/viewvc?rev=409336&view=rev
Log:
Bug fix for HARMONY-498 (GregorianCalendar clone problem) + regression test.
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=409336&r1=409335&r2=409336&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 Thu May 25 02:04:28 2006
@@ -278,7 +278,18 @@
complete();
}
- private final void fullFieldsCalc(long timeVal, int millis, int zoneOffset) {
+ /**
+ * Creates new instance of GregorianCalendar with the same properties.
+ *
+ * @return a shallow copy of this GregorianCalendar
+ */
+ public Object clone(){
+ GregorianCalendar thisClone = (GregorianCalendar)super.clone();
+ thisClone.cachedFields = (int[])cachedFields.clone();
+ return thisClone;
+ }
+
+ private final void fullFieldsCalc(long timeVal, int millis, int zoneOffset) {
long days = timeVal / 86400000;
if (millis < 0) {
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=409336&r1=409335&r2=409336&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 Thu May 25 02:04:28 2006
@@ -540,6 +540,26 @@
gc1.getGregorianChange()));
}
+ /**
+ * @tests java.util.GregorianCalendar#clone()
+ */
+ public void test_clone() {
+
+ // Regression for HARMONY-498
+ GregorianCalendar gCalend = new GregorianCalendar();
+
+ gCalend.set(Calendar.MILLISECOND, 0);
+ int dayOfMonth = gCalend.get(Calendar.DAY_OF_MONTH);
+
+ // create clone object and change date
+ GregorianCalendar gCalendClone = (GregorianCalendar) gCalend.clone();
+ gCalendClone.add(Calendar.DATE, 1);
+
+ assertEquals("Before", dayOfMonth, gCalend.get(Calendar.DAY_OF_MONTH));
+ gCalend.set(Calendar.MILLISECOND, 0);//changes nothing
+ assertEquals("After", dayOfMonth, gCalend.get(Calendar.DAY_OF_MONTH));
+ }
+
/**
* Sets up the fixture, for example, open a network connection. This method
* is called before a test is executed.