How to get previous 7 dates from a particular date in java?I am getting 7 dates from present date, but I want from particular date
问题 //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