fork download
  1. import java.time.LocalDate;
  2. import java.time.ZoneId;
  3. import java.time.format.DateTimeFormatter;
  4. import java.time.format.TextStyle;
  5. import java.util.Locale;
  6.  
  7. public class Main {
  8. public static void main(String[] args) {
  9. // If you want to deal with the system timezone, you can simply use
  10. // LocalDate.now() instead of LocalDate.now(ZoneId.systemDefault()). In order to
  11. // deal with a specific timezone, replace ZoneId.systemDefault() with the
  12. // applicable ZoneId e.g. ZoneId.of("Asia/Kabul")
  13. LocalDate date = LocalDate.now(ZoneId.systemDefault());
  14.  
  15. String dow = date.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.ENGLISH);
  16. System.out.println(dow);
  17.  
  18. // Alternatively,
  19. DateTimeFormatter dtf = DateTimeFormatter.ofPattern("EEEE", Locale.ENGLISH);
  20. dow = dtf.format(date);
  21. System.out.println(dow);
  22. }
  23. }
Success #stdin #stdout 0.15s 54664KB
stdin
Standard input is empty
stdout
Tuesday
Tuesday