• Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding days to Calendar  RSS feed

 
Arjunkumar Shastry
Ranch Hand
Posts: 986
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16058
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!