Rob Prime wrote:You already have a class that can do what you want. You want to add one year to the calendar object. Are you sure you can't find a method to do that?
Um, in the code shown so far, he doesn't have a calendar; he has a Date. There are methods in Date that could conceivably be used here, but the API says they're deprecated, and we should use methods in Calendar or GregorianCalendar instead. So that's why he's looking into new classes like GregorianCalendar.
Pramod, can you show what you've tried with GregorianCalendar, or tell us what part of the API is confusing? Sadly, I know
many parts of
Java's date.time.calendar stuff can be confusing - we just need to focus on the particular part or parts you're having trouble with.
Googling things like "java GregorianCalendar examples" can also be helpful here.
Also I suggest paying careful attention to the difference between getDay() or get(Calendar.DAY) with getDate() or get(Calendar.DATE). I think this is actually the biggest problem with your original code.