Java Program to list Short Weekday Names


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

Updated on: 27-Jun-2020

309 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements