JDK-4830050 : BuddhistCalendar: add(year) can't handle negative value after 543 year are left
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2003-03-10
  • Updated: 2003-03-14
  • Resolved: 2003-03-14
Related Reports
Duplicate :  
Relates :  
Description
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

Comments
EVALUATION One of the known restrictions of the current BuddhistCalendar implementation in 1.4.x. A more complete implementation should be provided as a part of 4609228. ###@###.### 2003-03-11 This is the same limitation of the current BuddhistCalendar implementation as 4830072. Closing as a duplicate. ###@###.### 2003-03-14
11-03-2003