//获取指定时间前N天后N天
@Test
// public void getLastDay(String time){
public void getLastDay(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
Date date=null;
try {
date = sdf.parse("2022-8-24");
// date = sdf.parse(time);
} catch (ParseException e) {
e.printStackTrace();
}
calendar.setTime(date);
int day=calendar.get(Calendar.DATE);
// 此处修改为+1则是获取后一天
// calendar.set(Calendar.DATE,day-3);
calendar.set(Calendar.DATE,day+3);
String lastDay = sdf.format(calendar.getTime());
System.out.println("lastDay = " + lastDay);
// return lastDay;
}