import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.ResolverStyle;
import java.time.temporal.ChronoUnit;
class TesteData {
public static boolean fimDeSemana(LocalDate ld) {
DayOfWeek d = ld.getDayOfWeek();
return d == DayOfWeek.SATURDAY || d == DayOfWeek.SUNDAY;
}
public static LocalDate mais2DiasUteis(LocalDate ld) {
LocalDate novaData = ld.plus(2, ChronoUnit.DAYS);
while (fimDeSemana(novaData)) {
novaData = novaData.plus(1, ChronoUnit.DAYS);
}
return novaData;
}
public static void main
(String[] args
) { DateTimeFormatter fmt = DateTimeFormatter
.ofPattern("dd/MM/uuuu")
.withResolverStyle(ResolverStyle.STRICT);
LocalDate algumaData1 = mais2DiasUteis(LocalDate.parse("04/09/2018", fmt));
LocalDate hoje1 = LocalDate.parse("05/09/2018", fmt); //LocalDate.now();
boolean antes1 = algumaData1.isBefore(hoje1);
System.
out.
println(antes1
+ " - " + fmt.
format(algumaData1
) + " - " + fmt.
format(hoje1
));
LocalDate algumaData2 = mais2DiasUteis(LocalDate.parse("06/09/2018", fmt));
LocalDate hoje2 = LocalDate.parse("10/09/2018", fmt); //LocalDate.now();
boolean antes2 = algumaData2.isBefore(hoje2);
System.
out.
println(antes2
+ " - " + fmt.
format(algumaData2
) + " - " + fmt.
format(hoje2
));
LocalDate algumaData3 = mais2DiasUteis(LocalDate.parse("06/09/2018", fmt));
LocalDate hoje3 = LocalDate.parse("11/09/2018", fmt); //LocalDate.now();
boolean antes3 = algumaData3.isBefore(hoje3);
System.
out.
println(antes3
+ " - " + fmt.
format(algumaData3
) + " - " + fmt.
format(hoje3
)); }
}
aW1wb3J0IGphdmEudGltZS5EYXlPZldlZWs7CmltcG9ydCBqYXZhLnRpbWUuTG9jYWxEYXRlOwppbXBvcnQgamF2YS50aW1lLmZvcm1hdC5EYXRlVGltZUZvcm1hdHRlcjsKaW1wb3J0IGphdmEudGltZS5mb3JtYXQuUmVzb2x2ZXJTdHlsZTsKaW1wb3J0I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