Problem with java.util.Calendar
I have a Problem with java.util.Calendar.
It is best expressed by the following short main function:
import java.util.*;
public class CalendarProblem {
public static void main(String[] args) {
// problem also encountered in other Locales
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT+0"),Locale.US);
cal.set(2004,8,31,0,0,1);
System.out.println(cal.get(Calendar.YEAR))); // 2004
// now the Problem
System.out.println(cal.get(Calendar.MONTH));// 9
System.out.println(cal.get(Calendar.DAY_OF_MONTH));// 1
}
}
Although set to the 31st of August, Calendar produces the 1st of September.
Why is that? Is it a bug, or am I using the class wrongly?
Even calling .clear() before setting the time does not help.
Moreover, setting the time by a java.util.Date leads to the same result.
I executed the code under J2SE 1.3.1 .
I'd appreciate any hints.

