File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Rolling Dates With java.util.GregorianCalendar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Rolling Dates With java.util.GregorianCalendar" Watch "Rolling Dates With java.util.GregorianCalendar" New topic

Rolling Dates With java.util.GregorianCalendar

Kawika King

Joined: Dec 18, 2002
Posts: 7
I have a combo box that is populated with dates, starting with today and adding 14days. Ex.
Dec 18, 2002
Dec 19, 2002
Anyone know how would I change the year so that I can roll over to 2003 or 2004?
Dec 31, 2002
Jan 1, 2003 ???
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

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.
[ December 19, 2002: Message edited by: Rene Larsen ]

Regards, Rene Larsen
Dropbox Invite
I agree. Here's the link:
subject: Rolling Dates With java.util.GregorianCalendar
It's not a secret anymore!