Here you can find the source of adjustDate(Calendar calendar, int differenceInDay)
Parameter | Description |
---|---|
calendar | the Calendar object to be adjusted. |
differenceInDay | the difference in days. It accepts both position and negative number. |
public static Calendar adjustDate(Calendar calendar, int differenceInDay)
//package com.java2s; import java.util.Calendar; public class Main { private static final long DAY_IN_MS = 24 * 60 * 60 * 1000; /**// ww w. ja v a 2 s . c o m * Adjusts the Calendar to several days before or after the current date. * * @param calendar the Calendar object to be adjusted. * @param differenceInDay the difference in days. It accepts both position and negative number. * @return the calendar after the adjustment. It should always be the same instance as the calendar parameter. */ public static Calendar adjustDate(Calendar calendar, int differenceInDay) { calendar.setTimeInMillis(calendar.getTimeInMillis() + DAY_IN_MS * differenceInDay); return calendar; } }