LocalDate fechaProceso = r.getFechaProceso();
DayOfWeek dow;
Set<DayOfWeek> weekend = EnumSet.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY);
Boolean todayIsWeekend;
LocalDate fechaValor = null;
int i = 1;
while (i <= corr.getDiasValor()) {
fechaValor = fechaProceso.plusDays(i);
dow = fechaValor.getDayOfWeek();
todayIsWeekend = weekend.contains(dow);
if (todayIsWeekend) {
fechaValor.plusDays(2);
}
i++;
}
What I am trying to do is add to a date(fechaValor) one day but when it is in order to ignore those days. That is, if I am on Friday 2021-09-10 and I want to add one more day than add two more (that is, skipping Saturday and Sunday) and going to Monday, that is, the next day would be 2021-09-13.
What can i do? Actually my code is not working
EDIT2(not working neither):
switch (fechaProceso.getDayOfWeek()) {
// when it's a Friday, then add three days to get next Monday
case FRIDAY:
fechaValor = fechaProceso.plusDays(corr.getDiasValor() + 3) ;
// on Saturday, add 2 days
case SATURDAY:
fechaValor = fechaProceso.plusDays(corr.getDiasValor() + 2) ;
// in all other cases add just 1 day
default:
fechaValor = fechaProceso.plusDays(corr.getDiasValor() + 1) ;
}