I know there is the same question here, but I have tried the answer provided and it returned an output that I don\'t understand. I am confused by the answer and I don\'t thi
Just a suggestion - Instead of looping, you could just use the switch statement along with the Calendar.add() like this:
int weekdayNum = c.get(Calendar.DAY_OF_WEEK);
switch (weekdayNum) {
case 1: {
c.add(Calendar.DAY_OF_MONTH, 1);
break;
}
case 3: {
c.add(Calendar.DAY_OF_MONTH, 6);
break;
}
case 4: {
c.add(Calendar.DAY_OF_MONTH, 5);
break;
}
case 5: {
c.add(Calendar.DAY_OF_MONTH, 4);
break;
}
case 6: {
c.add(Calendar.DAY_OF_MONTH, 3);
break;
}
case 7: {
c.add(Calendar.DAY_OF_MONTH, 2);
break;
}
default:
break;
}