I am using the following code to get the current date and the next dates.
List<String> list=new ArrayList();
int nextWeekId=2;
int currentWeekId=1;
LocalDate localDate = LocalDate.now();
for (int i = 0; i < list.size(); i++) {
if (i >= 7) {
saveDetails(nextWeekId,list.get(i), java.sql.Date.valueOf(localDate.plusDays(i)));
} else {
saveDetails(currentWeekId, list.get(i), java.sql.Date.valueOf(localDate.plusDays(i)));
}
}
My list size will always the size = 14. The week should always start on Monday. I want that if for example today is Friday and date is 2020-07-10. Then my system will store the date 2020-07-10 , 2020-07-11 , 2020-07-12 against currentWeekId and the complete next seven days against nextWeekId.
The order of accessing the values doesn't matter.