How to Increment and Decrement Date in JAVA

Let’s see, How can you increment and decrement Date in Java. In Java, we need to perform operations on Date like Add date in current date or Subtract date from Current Date. Sometimes we need to get the tomorrow date or yesterday date.


In Java, you can achieve the Date operation using two ways. First one is using Calendar (java.util.Calendar) class of JDK and another way is using DateUtils class from Apache common lang library.


Increment and Decrement Date in Java with Example

Let’s understand this using a simple example. In below example, We will look into the both ways to perform the operations on Dates.

To use the Calendar class, you don’t need to configure any external library but to use Apache DateUtils class. First, you need to add Apache Common library into your project.

You can download the Apache Common lang library for here Download Apache Common Lang. Download the Zip file from here and unzip it. Now Add commons-lang.jar file into your project as an external jar file.


You can refer the above example to learn about the operations of Dates. You can see we are using getInstance() method of Calendar class, getInstance() load the current locale into account and return the calendar.

This is all about to add or subtract the days in the current date.

0 Comment

Leave a Reply