Ravibhushan
Ravibhushan

Reputation: 171

current Day + N days is the day of next month or previous month

ANDROID:

Wanted to know whether is there any API or workaround to know that DAY X + N DAYS ahead or behind was the day that will be / was of next month / previous month.

Upvotes: 0

Views: 278

Answers (1)

Bob
Bob

Reputation: 23010

public static Date getCurrentDatePlusDays(int days) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.DAY_OF_YEAR, days);
        Date newDate = calendar.getTime();
        return newDate;
    }

then check the month or year.

Upvotes: 1

Related Questions