Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with calendar

5 views
Skip to first unread message

Erwin

unread,
Aug 31, 2010, 12:07:12 PM8/31/10
to
i have a problem with calendar, and throws a exception called

java.lang.IllegalArgumentException: MONTH

Im getting the actual date and the two passed months with calendar

Does anybody know what it means that??

Fred

unread,
Aug 31, 2010, 12:24:06 PM8/31/10
to

Showing a little bit of your code would certainly help.
--
Fred K

rossum

unread,
Aug 31, 2010, 12:25:22 PM8/31/10
to
On Tue, 31 Aug 2010 09:07:12 -0700 (PDT), Erwin <erwin...@gmail.com>
wrote:

Without seeing your code I cannot be sure, but three thoughts occur to
me:

1 What parameter is the method that throws the exception expecting?
Check the Javadoc very carefully.

2 Does your code say "MONTH" or "Calendar.MONTH"?

3 MONTH values run from 0 (January) to 11 (December) which might not
be what you were expecting. You can also have 12 for Undecimber, but
not many people use that.

rossum

Roedy Green

unread,
Sep 1, 2010, 12:35:48 PM9/1/10
to
On Tue, 31 Aug 2010 09:07:12 -0700 (PDT), Erwin <erwin...@gmail.com>
wrote, quoted or indirectly quoted someone who said :

What method is causing the exception? what values are you passing to
it?

Note that in GregorianCalendar, January is month 0. In contrast, in
DateFormat, January is month 1.
--
Roedy Green Canadian Mind Products
http://mindprod.com

You encapsulate not just to save typing, but more importantly, to make it easy and safe to change the code later, since you then need change the logic in only one place. Without it, you might fail to change the logic in all the places it occurs.

Arne Vajhøj

unread,
Sep 4, 2010, 11:50:23 AM9/4/10
to
On 01-09-2010 12:35, Roedy Green wrote:
> On Tue, 31 Aug 2010 09:07:12 -0700 (PDT), Erwin<erwin...@gmail.com>
> wrote, quoted or indirectly quoted someone who said :
>> i have a problem with calendar, and throws a exception called
>>
>> java.lang.IllegalArgumentException: MONTH
>>
>> Im getting the actual date and the two passed months with calendar
>>
>> Does anybody know what it means that??
>
> What method is causing the exception? what values are you passing to
> it?
>
> Note that in GregorianCalendar, January is month 0. In contrast, in
> DateFormat, January is month 1.

The constant Calendar.JANUARY has a numeric value of 0.

If people use the API as intended, then the numeric
values does not matter - it is just an opaque indication of
a specific month.

To say that January is "month 0" is using the API the
wrong way.

Arne


0 new messages