Ingo said:
Because everyone would think that it is specified different. E.g. when
you want the user to enter a month (e.g. "6" for "June"), then you
cannot set this month with
calendar.setMonth(m)
but instead you have to use
calendar.setMonth(new Calender(new
SimpleDateFormat("MM").format(m).getTime()).get(Calendar.MONTH))
or something like that (I guess it gets even more complicated because
there is no such constructor for Calender)...
Well, you are right, this is very clumsy. But if you know that the user inputs
the month as a number, then why don't you just use calendar.setMonth(m-1)?
Also, in your example, you omitted a line of code: In general, I would assume
that the user has entered a *string*, so you have to use a parser anyway to make
it a month. Using Integer.parseInt(String) is the wrong decision anyway because
it returns an integer and not a month. Hence, you need to replace it by
DateFormat.parse(String)
On the other hand, if you use a combo box or something, you can get the indices
right in the first place. Then, starting with 0 is making it easier, I think.
Apart from that, I have never encountered an application where the user enters
*only* a month, and if he enters a whole date you need a DateFormat anyway.
You could design a programming language whose array-indices start with
-3, that would make as much sense.
So you want array-indices to start with 1? I don't see the analogy.
Making January=0 was a design decision which has advantages and disadvantages. I
would not consider it a heavy bug, though.
Cheers,
Simon