Home » Android » java – Android how to get tomorrow's date

java – Android how to get tomorrow's date

Posted by: admin April 23, 2020 Leave a comment


In my android application. I need to display tomorrow’s date, for example today is 5th March so I need to display as 6 March. I know the code for getting today’s date, month and year.

date calculating

    GregorianCalendar gc = new GregorianCalendar();
    yearat = gc.get(Calendar.YEAR);
    yearstr = Integer.toString(yearat);
    monthat = gc.get(Calendar.MONTH) + 1;
    monthstr = Integer.toString(monthat);
    dayat = gc.get(Calendar.DAY_OF_MONTH);
    daystr = Integer.toString(dayat);

If I have the code

dayat = gc.get(Calendar.DAY_OF_MONTH) + 1;

will it display tomorrow’s date. or just add one to today’s date? For example, if today is January 31. With the above code, will it display like 1 or 32? If it displays 32, what change I need to make?

How to&Answers:
  1. Get today’s date as a Calendar.

  2. Add 1 day to it.

  3. Format for display purposes.

For example,

GregorianCalendar gc = new GregorianCalendar();
gc.add(Calendar.DATE, 1);
// now do something with the calendar


Use the following code to display tomorrow date

Calendar calendar = Calendar.getInstance();
Date today = calendar.getTime();

calendar.add(Calendar.DAY_OF_YEAR, 1);
Date tomorrow = calendar.getTime();

Use SimpleDateFormat to format the Date as a String:

DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");

String todayAsString = dateFormat.format(today);
String tomorrowAsString = dateFormat.format(tomorrow);





Calendar calendar = Calendar.getInstance();
Date today = calendar.getTime();

calendar.add(Calendar.DAY_OF_YEAR, 1);
Date tomorrow = calendar.getTime();


java.util.Date and java.util.Calendar are terrible to work with. I suggest you use JodaTime which has a much cleaner / nicer API. JodaTime is pretty standard these days.


Note that JDK 8 will introduce a new date/time API heavily influenced by JodaTime.


you have to add just 1 in your Calendar Day.

GregorianCalendar gc = new GregorianCalendar();
gc.add(Calendar.DATE, 1);


Other options:

Calendar tomorrow = Calendar.getInstance();
tomorrow.roll(Calendar.DATE, true);


tomorrow.roll(Calendar.DATE, 1);

roll can also be used to go back in time by passing a negative number, so for example:

Calendar yesterday = Calendar.getInstance();
yesterday.roll(Calendar.DATE, -1);


the first answers pretty much covers the possibilities.
but here one another solution which you can use from org.apache.commons.lang.time:

Date lTomorrow = DateUtils.addDays(new Date(), 1);


The java.util.Date and .Calendar classes are notoriously troublesome. Avoid them. Instead use either Joda-Time library or the new java.time package in bundled with Java 8.

Some example code using the Joda-Time 2.3 library.

DateTimeZone timeZone = DateTimeZone.forID( "Europe/Paris" );
DateTime now = new DateTime( timeZone );
DateTime tomorrow = now.plusDays( 1 );
String output = DateTimeFormat.forPattern( "FF" ).withLocale(Locale.FRANCE).print( tomorrow );


Get todays date by using calendar and then add 1 day to it.


This is working to me well!!

    Date currentDate = new Date();// get the current date
    currentDate.setDate(currentDate.getDate() + 1);//add one day to the current date
    dateView.setText(currentDate.toString().substring(0, 10));// put the string in specific format in my textView

good luck!!


Try like this..

dayat = gc.add(Calendar.DATE, 1);



                   .plusDays( 1 ) 


All the other Answers are outmoded, using the troublesome old Date & Calendar classes or the Joda-Time project which is now in maintenance mode. The modern approach uses the java.time classes.


The LocalDate class represents a date-only value without time-of-day and without time zone.

A time zone is crucial in determining a date. For any given moment, the date varies around the globe by zone. For example, a few minutes after midnight in Paris France is a new day while still “yesterday” in Montréal Québec.

If no time zone is specified, the JVM implicitly applies its current default time zone. That default may change at any moment, so your results may vary. Better to specify your desired/expected time zone explicitly as an argument.

Specify a proper time zone name in the format of continent/region, such as America/Montreal, Africa/Casablanca, or Pacific/Auckland. Never use the 3-4 letter abbreviation such as EST or IST as they are not true time zones, not standardized, and not even unique(!).

ZoneId z = ZoneId.of( "America/Montreal" ) ;
LocalDate today = LocalDate.now( z ) ;

From that LocalDate you can do math to get the following day.

LocalDate tomorrow = today.plusDays( 1 ) ;


To generate a String representing the LocalDate object’s value, call toString for text formatted per the ISO 8601 standard: YYYY-MM-DD.

To generate strings in other formats, search Stack Overflow for DateTimeFormatter.

About java.time

The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date, Calendar, & SimpleDateFormat.

The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.

To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.

Where to obtain the java.time classes?


Best way for setting next day is

 public void NextDate()

    final Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);

    // set current date into textview
    e_date.setText(new StringBuilder()
            // Month is 0 based, just add 1
            .append(mDay+1).append("-").append(mMonth + 1).append("-")
            .append(mYear).append(" "));



Just call this method and send date from which you want next date     

public String nextDate(Date dateClicked) {
String next_day;
            SimpleDateFormat dateFormatForDisplaying = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault());
            String date_format = dateFormatForDisplaying.format(dateClicked);
            SimpleDateFormat simpleDateformat = new SimpleDateFormat("E"); // the day of the week abbreviated
            final Calendar calendar = Calendar.getInstance();
            try {
                Date date = dateFormatForDisplaying.parse(date_format);
                calendar.add(Calendar.DATE, 1);
                String nex = dateFormatForDisplaying.format(calendar.getTime());
                Date d1 = dateFormatForDisplaying.parse(nex);
                String day_1 = simpleDateformat.format(d1);
                next_day = nex + ", " + day_1;
            } catch (ParseException e) {

            return next_day;



 String  lastDate="5/28/2018";
        Calendar calendar = Calendar.getInstance();
        String[] sDate=lastDate.split("/");

        DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");

//        String todayAsString = dateFormat.format(today);

        for (int i=1;i<29;i++)
//            td[i].setText(dateFormat.format(calendar.getTime()));