aspose file tools
The moose likes Java in General and the fly likes Adding days to Calendar Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Adding days to Calendar" Watch "Adding days to Calendar" New topic
Author

Adding days to Calendar

Arjunkumar Shastry
Ranch Hand

Joined: Feb 28, 2005
Posts: 986
GregorianCalendar allows to add X amount of days/minutes etc.But those changes are only for that Calendar.I need new instance of GregorianCalendar which will be X days ahead of another GregorianCalandar.add() method does not retutn new GregorianCalendar.


Namma Suvarna Karnataka
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12928
    
    3

Create a new instance of GregorianCalendar and set the date and time of the new instance to the same as the old one (lookup the API documentation for the methods you need).

Then add the number of days to the new one by using the add() method.
[ June 09, 2006: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
jQuery in Action, 2nd edition
 
subject: Adding days to Calendar
 
Similar Threads
newbie needs to know how do get todays date
WEEK_OF_MONTH with alternate result
One more GregorianCalendar question
Gregarion Calendar causing problem when adding dates.....
subtracting days from GregorianCalendar