Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8350541

Can not set BuddhistCalendar year less than or equal to 543 when setLenient(false).

XMLWordPrintable

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

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: