Here is my program, I tried
java.sql.Date logicalDate;
Calendar c = Calendar.getInstance();
c.setTime(logicalDate);
c.add(Calendar.DATE, 1);
import java.sql.Date;
import java.time.LocalTime;
import java.util.Calendar;
import java.util.List;
import java.util.stream.Collectors;
public class Test {
public static void main(String a[]) {
java.sql.Date todaysDate = new java.sql.Date(new java.util.Date().getTime());
int futureDay =1;
int pastDay=2;
java.sql.Date futureDate = this.addDays(todaysDate, futureDay);
java.sql.Date pastDate = this.subtractDays(todaysDate, pastDay);
System.out.println("futureDate =>>> " + futureDate);
System.out.println("pastDate =>>> " + pastDate);
}
public static Date addDays(Date date, int days) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, days);
return new Date(c.getTimeInMillis());
}
public static Date subtractDays(Date date, int days) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.DATE, -days);
return new Date(c.getTimeInMillis());
}
}