Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rolling Dates With java.util.GregorianCalendar

 
Kawika King
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a combo box that is populated with dates, starting with today and adding 14days. Ex.
Dec 18, 2002
Dec 19, 2002
etc..
Anyone know how would I change the year so that I can roll over to 2003 or 2004?
Dec 31, 2002
Jan 1, 2003 ???
Thanks
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If you use this code, you'll add 1 year.

This will add 2 month. If more then a year it will automatic add 1 to the year.

This will add 3 days. If more then a month, it will automatic add 1 to the month, and if more then a year it will automatic add 1 to the year.
Lap year will also automatic be checked.
Rene
[ December 19, 2002: Message edited by: Rene Larsen ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic