Friday, April 3, 2026
HomeLanguagesJavaDateFormatSymbols getShortWeekdays() Method in Java with Examples

DateFormatSymbols getShortWeekdays() Method in Java with Examples

The getShortWeekdays() Method of DateFormatSymbols class in Java is used to get the short names of the weekdays of the calendar in a string format. For eg., “Sun” for Sunday, “Mon” for Monday etc.

Syntax:

public String[] getShortWeekdays()

Parameters: The method does not take any parameters.

Return Values: The method returns the short name of the weekdays in a string format.

Below programs illustrate the use of getShortWeekdays() method.
Example 1:




// Java code to demonstrate getShortWeekdays()
  
import java.text.DateFormatSymbols;
  
public class DateFormat_Main {
    public static void main(String args[])
    {
        int i;
  
        // Initializing DateFormatSymbols
        String shwkdays[]
            = new DateFormatSymbols().getShortWeekdays();
  
        for (i = 1; i < shwkdays.length; i++) {
  
            // Displaying the short names of weekdays
            System.out.println("Day " + i
                               + " = " + shwkdays[i]);
        }
    }
}


Output:

Day 1 = Sun
Day 2 = Mon
Day 3 = Tue
Day 4 = Wed
Day 5 = Thu
Day 6 = Fri
Day 7 = Sat

Example 2:




// Java code to demonstrate getShortWeekdays()
import java.text.DateFormatSymbols;
  
public class DateFormat_Main {
    public static void main(String args[])
    {
        int i;
  
        // Initializing DateFormatSymbols
        String shwkdays[]
            = new DateFormatSymbols().getShortWeekdays();
  
        for (i = 1; i < shwkdays.length / 2; i++) {
  
            // Displaying the short names of weekdays
            System.out.println("Day " + i
                               + " = " + shwkdays[i]);
        }
    }
}


Output:

Day 1 = Sun
Day 2 = Mon
Day 3 = Tue

Reference: https://docs.oracle.com/javase/8/docs/api/java/text/DateFormatSymbols.html#getShortWeekdays–

RELATED ARTICLES

Most Popular

Dominic
32512 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6886 POSTS0 COMMENTS
Nicole Veronica
12006 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12100 POSTS0 COMMENTS
Shaida Kate Naidoo
7015 POSTS0 COMMENTS
Ted Musemwa
7259 POSTS0 COMMENTS
Thapelo Manthata
6972 POSTS0 COMMENTS
Umr Jansen
6960 POSTS0 COMMENTS