fork(1) download
  1. import java.time.DayOfWeek;
  2. import java.time.LocalDate;
  3.  
  4. class Teste {
  5.  
  6. public static boolean fimDeSemana(LocalDate ld) {
  7. DayOfWeek d = ld.getDayOfWeek();
  8. return d == DayOfWeek.SATURDAY || d == DayOfWeek.SUNDAY;
  9. }
  10.  
  11. public static void main(String[] args) {
  12. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 19))); // false, terça-feira
  13. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 20))); // false, quarta-feira
  14. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 21))); // false, quinta-feira
  15. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 22))); // false, sexta-feira
  16. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 23))); // true, sábado
  17. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 24))); // true, domingo
  18. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 25))); // false, segunda-feira
  19. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 26))); // false, terça-feira
  20. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 27))); // false, quarta-feira
  21. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 28))); // false, quinta-feira
  22. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 29))); // false, sexta-feira
  23. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 30))); // true, sábado
  24. System.out.println(fimDeSemana(LocalDate.of(2017, 12, 31))); // true, domingo
  25. System.out.println(fimDeSemana(LocalDate.of(2018, 1, 1))); // false, segunda-feira
  26. }
  27. }
Success #stdin #stdout 0.25s 33440KB
stdin
Standard input is empty
stdout
false
false
false
false
true
true
false
false
false
false
false
true
true
false