fork download
  1. import java.time.DayOfWeek;
  2. import java.time.ZoneId;
  3. import java.time.ZonedDateTime;
  4. import java.time.temporal.WeekFields;
  5.  
  6. public class Main {
  7. public static void main(String[] args) {
  8. // Replace ZoneId.systemDefault() with the required ZoneId e.g. ZoneId.of("Europe/London)
  9. ZonedDateTime zdt = ZonedDateTime.now(ZoneId.systemDefault());
  10. DayOfWeek dow = zdt.getDayOfWeek();
  11. System.out.println(dow);
  12. System.out.println(dow.getValue()); // Monday is day-1
  13.  
  14. // In case you need Sunday as day-1
  15. System.out.println(zdt.get(WeekFields.SUNDAY_START.dayOfWeek())); // Sunday is day-1
  16. }
  17. }
Success #stdin #stdout 0.11s 55508KB
stdin
Standard input is empty
stdout
THURSDAY
4
5