//explain
public class DateLoop {
static String finalDate;
static String particularDate;
public static void main(String[] args) {
// TODO Auto-generated method stub
SimpleDateFormat sdf = new SimpleDateFormat("d-M-yyyy ");
Calendar cal = Calendar.getInstance();
particularDate = "2-1-2018";
// get starting date
cal.add(Calendar.DAY_OF_YEAR, -7);
// loop adding one day in each iteration
for(int i = 0; i< 7; i++){
cal.add(Calendar.DAY_OF_YEAR, 1);
finalDate =sdf.format(cal.getTime());
System.out.println(finalDate);
//ie, its giving previous 7 dates from present date, but I want
//particular date... thanks in advance
}
}
}
即,它给出了从当前日期开始的前 7 个日期,但我想要从特定日期开始的前 7 个日期。