Why is it that Java calendar only has 28 days for January 2004?

I tried using Java Calendar and I realized that January 2004 has only 28 days.
I added 2 days to the date 28 January 2004 , but the returned date is 2 Feb 2004...
Y is it so?

agamarjoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mick BarryJava DeveloperCommented:
post your code
smitty22Commented:
Remember, it's zero-based:

0 = january
1 = february
2 = may
smitty22Commented:
2 = march, that is
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

zzynxSr. Software engineerCommented:
The following code snippet

      java.text.SimpleDateFormat dayFormatter =
        new java.text.SimpleDateFormat("dd/MM/yyyy");
      java.util.Calendar c = java.util.Calendar.getInstance();
      c.set(2004,0,28);
      c.add(java.util.Calendar.DATE, 2);
      System.out.println(dayFormatter.format(c.getTime()));

nicely prints out:

       30/01/2004

Hope this is helpful to you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jimmackCommented:
I still haven't seen a good reason, but smitty22 is right, months are numbered 0 .. 11.

Days and years use the actual values.
zzynxSr. Software engineerCommented:
Hi Agamarjo,
Thanks for the acceptance.

For helping me answering future questions better, can you tell me what I could have done better to deserve an A grade?

Kind regards.
jimmackCommented:
That's a grade 'A' answer.
zzynxSr. Software engineerCommented:
Hi jimmack,
Thanks for sharing your opinion (and thus strengthen mine)
The fact that the author of the question keeps quiet proves s/he thinks the same way about it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.