Here you can find the source of adjustDays(Date startingDate, int deltaDays)
Parameter | Description |
---|---|
startingDate | Date to be altered |
deltaDays | Number of days to be moved. Use positive integers for a move to the future, and a negative number for a change to the past. |
public static Date adjustDays(Date startingDate, int deltaDays)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { /**//from ww w . j a v a 2 s .c om * Takes a {@link Date} and moves in the desired amount of days. * @param startingDate Date to be altered * @param deltaDays Number of days to be moved. Use positive integers for a move to the future, and a negative number for a change to the past. * @return returns the new Date */ public static Date adjustDays(Date startingDate, int deltaDays) { Calendar cal = Calendar.getInstance(); cal.setTime(startingDate); cal.add(Calendar.DATE, deltaDays); return cal.getTime(); } }