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

BuddhistCalendar: add(year) can't handle negative value after 543 year are left

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs

      1) when the Thai year is 2546.
      if add -2002, the year output is 544 (correct)
      if add -2003, the year output is 544 (expecting 543)
                    after add 14 month, the year is still 544
      if add -2004, the year output is 545 (expecting 542)
                    after add 14 month, the year is still 544
      if add -2400, the year output is 941 (expecting 146)
                    after add 14 month, the year is 940
      if add -3000, the year output is 1541 (expecting ???)
                    after add 14 month, the year is 1540

      Please compile and run the attached code with jdk1.4.2-b17.
      =============================
      import java.util.*;

      public class AddTest{
         public static void main(String[] args){
            int[] integers = {-2002, -2003, -2004, -2400, -3000};
            for(int i = 0; i<integers.length; i++){
              Calendar budcal = Calendar.getInstance(new Locale("th", "TH"));
              System.out.println("Thai Year of now:"+budcal.get(Calendar.YEAR));
              budcal.add(Calendar.YEAR, integers[i]);
              System.out.println("Year after adding "+integers[i]+" year:"+budcal.get(Calendar.YEAR));
              System.out.println("Month of now:"+budcal.get(Calendar.MONTH));
              budcal.add(Calendar.MONTH, 14);
              System.out.println("Year after adding 14 month:"+budcal.get(Calendar.YEAR));
              System.out.println("Month after adding 14 month:"+budcal.get(Calendar.MONTH));
              System.out.println("");
            }
         }
      }

      output:
      ===========================
      Thai Year of now:2546
      Year after adding -2002 year:544
      Month of now:2
      Year after adding 14 month:545
      Month after adding 14 month:4

      Thai Year of now:2546
      Year after adding -2003 year:544
      Month of now:2
      Year after adding 14 month:544
      Month after adding 14 month:4

      Thai Year of now:2546
      Year after adding -2400 year:941
      Month of now:2
      Year after adding 14 month:940
      Month after adding 14 month:4

      Thai Year of now:2546
      Year after adding -3000 year:1541
      Month of now:2
      Year after adding 14 month:1540
      Month after adding 14 month:4

            okutsu Masayoshi Okutsu
            lzhanorcl Lichun Zhan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: