How do I Get a List of Weekday Names?

Category: java.text, viewed: 8216 time(s).

The example code below helps you to get all weekday names as an array of String. The first method, getWeekdays() return the full name string while the second method getShortWeekdays() return the short name of the weekday.

import java.text.DateFormatSymbols;

public class WeekdayNames
{
    public static void main(String[] args)
    {
        String[] weekdays = new DateFormatSymbols().getWeekdays();
        for (int i = 0; i < weekdays.length; i++)
        {
            String weekday = weekdays[i];
            System.out.println("weekday = " + weekday);
        }

        String[] shortWeekdays = new DateFormatSymbols().getShortWeekdays();
        for (int i = 0; i < shortWeekdays.length; i++)
        {
            String shortWeekday = shortWeekdays[i];
            System.out.println("shortWeekday = " + shortWeekday);
        }
    }
}

The result of the code above are:

weekday = Sunday
weekday = Monday
weekday = Tuesday
weekday = Wednesday
weekday = Thursday
weekday = Friday
weekday = Saturday

shortWeekday = Sun
shortWeekday = Mon
shortWeekday = Tue
shortWeekday = Wed
shortWeekday = Thu
shortWeekday = Fri
shortWeekday = Sat
Click here to lend your support to: Kode Java Org and make a donation at www.pledgie.com !

 

Uncensored Newsgroups
Download Hundreds of Complimentary Industry Resources

Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more; all available at no cost to you. With more than 600 complimentary offers, you'll find plenty of titles to suit your professional interests and needs. Click Here and Sign up today!

Java Training

Sponsored Links

Our Friends

Statistics

Locations of visitors to this page
visitor stats