Java Program to list Short Weekday Names

Java 8Object Oriented ProgrammingProgramming

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

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

Get short weekday names in an array

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

Display the weekday

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().getShortWeekdays();
      for (int i = 0; i < days.length; i++) {
         String weekday = days[i];
         System.out.println(weekday);
      }
   }
}

Output

Sun
Mon
Tue
Wed
Thu
Fri
Sat
raja
Published on 19-Dec-2018 10:03:24
Advertisements