Java Program to list Weekday names


To list weekday names, use the getWeekdays () from the DateFormatSymbols class in Java.

DateFormatSymbols is a class for encapsulating localizable date-time formatting data.

Get weekday month names in an array −

String[] days = new DateFormatSymbols().getWeekdays ();

Display the weekdays −

for (int i = 0; i < days.length; i++) {
   String weekday = days[i];
   System.out.println(weekday);
}

The following is an example −

Example

 Live Demo

import java.text.DateFormatSymbols;
public class Demo {
   public static void main(String[] args) {
      String[] days = new DateFormatSymbols().getWeekdays();
      for (int i = 0; i < days.length; i++) {
         String weekday = days[i];
         System.out.println(weekday);
      }
   }
}

Output

Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

Updated on: 27-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements