Avatar of sunshine737
sunshine737
 asked on

Having problem with Calendar

Hello,

I am setting the 2006/12/01 (YYYY/MM/DD) to the Calendar. When i retrieve the data i am getting 2007/00/01(YYYY/MM/DD).  I am getting the wrong month and year. I am getting this problem only for 12th month in any year. Please suggest me one good way. I used the following code for this.

I am using the Calendar object to set the date, moth and year.
Calendar calendar = Calendar.getInstance();
calendar.set(date.aYear, date.aMonth, date.aDay);

I am getting that data like below.
calendar.get(Calendar.YEAR);
calendar.get(Calendar.MONTH);
calendar.get(Calendar.DATE);


Thanks in advance.


Java

Avatar of undefined
Last Comment
Mick Barry

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mick Barry

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
sunshine737

ASKER

Thank you very much.

So i need to adjust(subtract one month) that month value before setting to the calendar right?

Is there any other possibilty without doing the above job?
Mick Barry

> So i need to adjust(subtract one month) that month value before setting to the calendar right?

correct

> Is there any other possibilty without doing the above job?

Not if you need to use set
Your help has saved me hundreds of hours of internet surfing.
fblack61