-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.2
-
generic
-
generic
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
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
- duplicates
-
JDK-4830072 BuddhistCalendar: set(year) can not set year before 543 correctly
- Closed
- relates to
-
JDK-4609228 (cal) RFE: Provide additional local calendars in Java
- Resolved