diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/IslamicCalendar.java b/icu4j/main/classes/core/src/com/ibm/icu/util/IslamicCalendar.java index 16d8caf9902..da254723474 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/IslamicCalendar.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/IslamicCalendar.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2008, International Business Machines Corporation and * + * Copyright (C) 1996-2010, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -438,7 +438,7 @@ public class IslamicCalendar extends Calendar { { // Make a guess at when the month started, using the average length long origin = HIJRA_MILLIS - + (long)Math.floor(month * CalendarAstronomer.SYNODIC_MONTH - 1) * ONE_DAY; + + (long)Math.floor(month * CalendarAstronomer.SYNODIC_MONTH) * ONE_DAY; double age = moonAge(origin); @@ -610,7 +610,7 @@ public class IslamicCalendar extends Calendar { monthStart = (long)Math.floor(months * CalendarAstronomer.SYNODIC_MONTH - 1); - if ( days - monthStart >= 28 && moonAge(internalGetTimeInMillis()) > 0) { + if ( days - monthStart >= 25 && moonAge(internalGetTimeInMillis()) > 0) { // If we're near the end of the month, assume next month and search backwards months++; } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java index 60f76066d6e..00e44c3d6dd 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (C) 1996-2005, International Business Machines Corporation and * + * Copyright (C) 1996-2010, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* */ @@ -143,6 +143,16 @@ public class IslamicTest extends CalendarTest { IslamicCalendar islamic = newCivil(); doLimitsTest(islamic, null, cal.getTime()); doTheoreticalLimitsTest(islamic, true); + + + // number of days to test - Islamic calendar starts to exhibit + // rounding errors after year AH3954 - about 2500 years out. + + IslamicCalendar islamic2 = new IslamicCalendar(); + islamic2.setCivil(false); + int testTime = getInclusion() <= 5 ? 20000 : 800000; + doLimitsTest(islamic2, null, cal.getTime(), testTime); + doTheoreticalLimitsTest(islamic2, true); } public void TestCoverage() {