Link to home
Create AccountLog in
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.


ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of sunshine737
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?
> 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