Increment and Decrement a Date Using the Calendar Class

This code example shows how to increment and decrement a date using an instance of the Calendar class.
The first method, incrementDate, increments the Calendar which is passed to the method by 5 days.
The second method, decrementDate, decrements the same Calendar instance with one month.

Since both the increment and decrement methods are called with the same instance of the Calendar class, the output from the code example showed this when it was executed:

Search for more Java info on this site here:
Custom Search

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">