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 ----------