Display weekday names in Java


To display weekday names in Java, use the getWeekdays() method.

For that, firstly import the following package.

import java.text.DateFormatSymbols;

Now, create a string array and get all the weekday names using the getWeekdays() method.

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

Example

 Live Demo

import java.text.DateFormatSymbols;
public class Demo {
   public static void main(String[] args) {
      String[] weekDays = new DateFormatSymbols().getWeekdays();
      System.out.println("Weekday names...");
      for(String days: weekDays){
      System.out.println(days);
   }
}
}

Output

Weekday names...

Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 26-Jun-2020

348 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements