Take the 2-minute tour ×

I want to add one day to a particular date. How can I do that?

Date dt = new Date();

Now I want to add one day to this date.

share|improve this question
possible duplicate of How can I increment a date by one day in Java? –  alain.janinm May 29 '12 at 18:09

12 Answers 12

up vote 119 down vote accepted

Given a Date dt you have several possibilities:

Solution 1: You can use the Calendar class for that:

Calendar c = Calendar.getInstance(); 
c.add(Calendar.DATE, 1);
dt = c.getTime();

Solution 2: You should seriously consider using the Joda-Time library, because of the various shortcomings of the Date class. With Joda-Time you can do the following:

DateTime dtOrg = new DateTime(dt);
DateTime dtPlusOne = dtOrg.plusDays(1);

Solution 3: With Java 8 you can also use the new JSR 310 API (which is inspired by Joda-Time):

share|improve this answer
Date today = new Date();
Date tomorrow = new Date(today.getTime() + (1000 * 60 * 60 * 24));

Date has a constructor using the milliseconds since the UNIX-epoch. the getTime()-method gives you that value. So adding the milliseconds for a day, does the trick. If you want to do such manipulations regularly I recommend to define constants for the values.

Important hint: That is not correct in all cases. Read the WARNING comment, below.

share|improve this answer
WARNING! Adding 1000*60*60*24 milliseconds to a java date will once in a great while add zero days or two days to the original date in the circumstances of leap seconds, daylight savings time and the like. If you need to be 100% certain only one day is added, this solution is not the one to use. –  Eric Leschinski Mar 13 '13 at 22:39
You are right. I add the hint to this comment to my answer. –  Mnementh Mar 14 '13 at 10:51
Downvoting since this is very much the wrong answer, due to both daylight saving time and leap seconds. Use Calendar or Joda time. –  stolsvik Feb 2 at 22:26
Leap seconds are not an issue in this context, as they are ignored by these date-time libraries: java.util.Date, Joda-Time, and java.time. The real problem with this answer is anomalies such as Daylight Savings Time that result in a day being other than exactly 24 hours long. –  Basil Bourque May 1 at 15:06

In core Java, Calendar is recommended for date manipulation.

Check this out: http://www.java2s.com/Tutorial/Java/0040__Data-Type/0580__Calendar.htm

share|improve this answer

This will increase any date by exactly one

String untildate="2011-10-08";//can take any date in current format    
Calendar cal = Calendar.getInstance();    
cal.setTime( dateFormat.parse(untildate));    
cal.add( Calendar.DATE, 1 );    
String convertedDate=dateFormat.format(cal.getTime());    
System.out.println("Date increase by one.."+convertedDate);
share|improve this answer

I would be careful using

Date today = new Date();    

If you are using a Calendar Timezone with Daytime Savings, on the changing day from summer to wintertime it will not jump to the next day.

share|improve this answer

To make it a touch less java specific, the basic principle would be to convert to some linear date format, julian days, modified julian days, seconds since some epoch, etc, add your day, and convert back.

The reason for doing this is that you farm out the "get the leap day, leap second, etc right' problem to someone who has, with some luck, not mucked this problem up.

I will caution you that getting these conversion routines right can be difficult. There are an amazing number of different ways that people mess up time, the most recent high profile example was MS's Zune. Dont' poke too much fun at MS though, it's easy to mess up. It doesn't help that there are multiple different time formats, say, TAI vs TT.

share|improve this answer

use DateTime object obj.Add to add what ever you want day hour and etc. Hope this works:)

share|improve this answer


The Joda-Time 2.3 library makes this kind of date-time work much easier. The java.util.Date class bundled with Java is notoriously troublesome, and should be avoided.

Here is some example code.

Your java.util.Date is converted to a Joda-Time DateTime object. Unlike a j.u.Date, a DateTime truly knows its assigned time zone. Time zone is crucial as adding a day to get the same wall-clock time tomorrow might mean making adjustments such as for a 23-hour or 25-hour day in the case of Daylight Saving Time (DST) here in the United States. If you specify the time zone, Joda-Time can make that kind of adjustment. After adding a day, we convert the DateTime object back into a java.util.Date object.

java.util.Date yourDate = new java.util.Date();

// Generally better to specify your time zone rather than rely on default.
org.joda.time.DateTimeZone timeZone = org.joda.time.DateTimeZone.forID( "America/Los_Angeles" );
DateTime now = new DateTime( yourDate, timeZone );
DateTime tomorrow = now.plusDays( 1 );
java.util.Date tomorrowAsJUDate = tomorrow.toDate();

Dump to console…

System.out.println( "yourDate: " + yourDate );
System.out.println( "now: " + now );
System.out.println( "tomorrow: " + tomorrow );
System.out.println( "tomorrowAsJUDate: " + tomorrowAsJUDate );

When run…

yourDate: Thu Apr 10 22:57:21 PDT 2014
now: 2014-04-10T22:57:21.535-07:00
tomorrow: 2014-04-11T22:57:21.535-07:00
tomorrowAsJUDate: Fri Apr 11 22:57:21 PDT 2014
share|improve this answer

Joda time handling the date time calculations with great flexibility and verity of methods. You can download the jar from here

share|improve this answer

I prefer joda for date and time arithmetics because it is much better readable:

Date tomorrow = now().plusDays(1).toDate();


share|improve this answer

As mentioned in the Top answer, since java 8 it is possible to do:

Date dt = new Date(); LocalDateTime.from(dt.toInstant()).plusDays(1);

but this can sometimes lead to an DateTimeException like this:

(java.time.DateTimeException: Unable to obtain LocalDateTime from TemporalAccessor: 2014-11-29T03:20:10.800Z of type java.time.Instant)

It is possible to avoid this Exception by simply passing the time zone:


share|improve this answer

In very special case If you asked to do your own date class, possibly from your Computer Programming Professor; This method would do very fine job.

  public void addOneDay()
    int [] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if (day> months[month-1])
        day = 1;
        if (month > 12)
            month = 1;
share|improve this answer

Your Answer


