JDK-8350541 : Can not set BuddhistCalendar year less than or equal to 543 when setLenient(false).
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 8,11,17,23,24,25
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2025-02-22
  • Updated: 2025-02-24
  • Resolved: 2025-02-24
Related Reports
Duplicate :  
Description
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 ----------


Comments
Looks like this is an implementation limitaion of the Thai Buddhist Calendar, where dates prior to Julian AD 1 are not correct. Closing it as a duplicate of the issue that decided not to fix it.
24-02-2025

The observations on Windows 11: JDK 8: Failed, IllegalArgumentException thrown JDK 11, 17, 23, 24, and 25ea+6: Failed.
23-02-2025