fork download
  1. import java.time.*;
  2. import java.util.Collection;
  3. import java.util.EnumSet;
  4.  
  5. public class Main {
  6. private static final Collection<DayOfWeek> DAY_SET = EnumSet.range(DayOfWeek.MONDAY, DayOfWeek.FRIDAY);
  7. public static void main(String[] args) {
  8. // ZoneId.systemDefault() gives you the ZoneId set to the JVM.
  9. // Change it as per your requirement e.g. ZoneId.of("Europe/London")
  10. LocalDate today = LocalDate.now(ZoneId.of("Europe/London"));
  11.  
  12. DayOfWeek dow = today.getDayOfWeek();
  13.  
  14. if (DAY_SET.contains(dow)) {
  15. System.out.println(dow);
  16. // Rest of the processing
  17. } else {
  18. System.out.println("Weekend");
  19. // Rest of the processing
  20. }
  21. }
  22. }
Success #stdin #stdout 0.11s 59344KB
stdin
Standard input is empty
stdout
THURSDAY