diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/EasterHoliday.java b/icu4j/main/classes/core/src/com/ibm/icu/util/EasterHoliday.java index f950a8b05f..702ce226c7 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/EasterHoliday.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/EasterHoliday.java @@ -154,8 +154,7 @@ class EasterRule implements DateRule { public EasterRule(int daysAfterEaster, boolean isOrthodox) { this.daysAfterEaster = daysAfterEaster; if (isOrthodox) { - orthodox.setGregorianChange(new Date(Long.MAX_VALUE)); - calendar = orthodox; + calendar.setGregorianChange(new Date(Long.MAX_VALUE)); } } @@ -288,9 +287,6 @@ class EasterRule implements DateRule { } } - private static GregorianCalendar gregorian = new GregorianCalendar(/* new SimpleTimeZone(0, "UTC") */); - private static GregorianCalendar orthodox = new GregorianCalendar(/* new SimpleTimeZone(0, "UTC") */); - private int daysAfterEaster; - private GregorianCalendar calendar = gregorian; + private GregorianCalendar calendar = new GregorianCalendar(); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HolidayTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HolidayTest.java index ac1425eaea..d76b644e4b 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HolidayTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/HolidayTest.java @@ -11,7 +11,6 @@ package com.ibm.icu.dev.test.calendar; import java.util.Date; import java.util.Locale; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -33,13 +32,14 @@ import com.ibm.icu.util.ULocale; */ @RunWith(JUnit4.class) public class HolidayTest extends TestFmwk { - @Before - public void init() throws Exception { - if(cal==null){ - cal = new GregorianCalendar(1, 0, 1); - longTimeAgo = cal.getTime(); - now = new Date(); - } + + // Do not use Before annotation, because TestFmwk's Before + // method must be executed first to initialize default time zone + @Override + protected void localTestInitialize() { + cal = new GregorianCalendar(1, 0, 1); + longTimeAgo = cal.getTime(); + now = new Date(); } private Calendar cal; diff --git a/icu4j/main/tests/framework/src/com/ibm/icu/dev/test/TestFmwk.java b/icu4j/main/tests/framework/src/com/ibm/icu/dev/test/TestFmwk.java index ce0082eddb..5871b6a8de 100644 --- a/icu4j/main/tests/framework/src/com/ibm/icu/dev/test/TestFmwk.java +++ b/icu4j/main/tests/framework/src/com/ibm/icu/dev/test/TestFmwk.java @@ -75,17 +75,38 @@ abstract public class TestFmwk extends AbstractTestLog { } @Before - public void testInitialize() { + public final void testInitialize() { Locale.setDefault(defaultLocale); TimeZone.setDefault(defaultTimeZone); if (getParams().testSecurityManager != null) { System.setSecurityManager(getParams().testSecurityManager); } + + localTestInitialize(); + } + + /** + * This method is called at the end of {@link #testInitialize()}. + * Because JUnit does not guarantee the order of multiple Before + * methods, TestFmwk implementation class should override this + * method, instead of annotating Before. + */ + protected void localTestInitialize() { + } + + /** + * This method is called at the beginning of {@link #testTeardown()}. + * TestFmwk implementation class hould override this method, instead + * of annotating After. + */ + protected void localTestTeardown() { } @After - public void testTeardown() { + public final void testTeardown() { + localTestTeardown(); + if (getParams().testSecurityManager != null) { System.setSecurityManager(getParams().originalSecurityManager); }