FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
also:
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
From wikipedia (http://en.wikipedia.org/wiki/Thai_solar_calendar):
"In 1941 (2484 B.E.), per decree by Prime Minister Phibunsongkhram, January 1 became the official start of a new year (so year 2483 B.E. had only nine months). When converting a date prior to that year, one should check whether it falls between January 1 and March 31: if so the number to add or subtract is 542, not 543."
The Calendar implementation returned for the Thai locale does not appear to model the 9 month year for 2483 B.E. According to the Calendar instance, that year has 12 normal Gregorian months which is historically incorrect..
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the attached code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
This simple program iterates backward from January 31st 2484(1941 - the first year that Thailand used the Gregorian calendar back through 2483 (1940) which should have been 9 months. The calendar instance should skip October, November and December.
ACTUAL -
The program shows dates for October, November and December 2483 B.E. (1940 A.D.)
This means that for dates prior to 1941, the Calendar implementation is be calculating the Buddhist Era date incorrectly by one year.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.Calendar;
import java.util.Locale;
public class Main extends java.lang.Object {
public static void main(String args[]) {
Locale locale = new Locale("th", "TH", "TH");
Calendar thaiCalendar = Calendar.getInstance(locale);
thaiCalendar.set(Calendar.YEAR, 2484);
thaiCalendar.set(Calendar.MONTH, 0);
thaiCalendar.set(Calendar.DAY_OF_MONTH, 32);
for(int i = 0; i < 600; i ++) {
int day = thaiCalendar.get(Calendar.DAY_OF_YEAR) - 1;
thaiCalendar.set(Calendar.DAY_OF_YEAR, day);
System.out.println(
thaiCalendar.get(Calendar.YEAR) + "-" +
thaiCalendar.get(Calendar.MONTH) + "-" +
thaiCalendar.get(Calendar.DAY_OF_MONTH));
}
}
}
---------- END SOURCE ----------
###@###.### 2005-03-29 12:12:42 GMT