-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8, 11, 17, 23, 24, 25
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
BuddhistCalendar extends GregorianCalendar, and uses a yearOffset(543). The first year in BuddhistCalendar is 543 BC.
When call "cal.set(year, 543)", it will subtract yearOffset, and call "set(year, 543 - yearOffset)" method of GregorianCalendar.
And Gregorian will check whether year is less than the minimum(the minimum is 1), and it will throw an exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java BuddhistCalendarTest.java
---------- BEGIN SOURCE ----------
import java.util.Calendar;
import java.util.Locale;
public class BuddhistCalendarTest {
public static void main(String[] args) {
Calendar buddhist = Calendar.getInstance(new Locale("th", "TH"));
buddhist.setLenient(false);
buddhist.set(Calendar.YEAR, 543);
System.out.println(buddhist.getTime());
}
}
---------- END SOURCE ----------
BuddhistCalendar extends GregorianCalendar, and uses a yearOffset(543). The first year in BuddhistCalendar is 543 BC.
When call "cal.set(year, 543)", it will subtract yearOffset, and call "set(year, 543 - yearOffset)" method of GregorianCalendar.
And Gregorian will check whether year is less than the minimum(the minimum is 1), and it will throw an exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java BuddhistCalendarTest.java
---------- BEGIN SOURCE ----------
import java.util.Calendar;
import java.util.Locale;
public class BuddhistCalendarTest {
public static void main(String[] args) {
Calendar buddhist = Calendar.getInstance(new Locale("th", "TH"));
buddhist.setLenient(false);
buddhist.set(Calendar.YEAR, 543);
System.out.println(buddhist.getTime());
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-4833267 (cal) BuddhistCalendar problems
-
- Closed
-