Web | This Site

Java Basics Examples
Java Tutorial
Java Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# Java Examples - Displaying weekdays

## Problem Description:

How to display name of the weekdays ?

## Solution:

This example displays the names of the weekdays in short form with the help of DateFormatSymbols().getWeekdays() method of DateFormatSymbols class.

    import java.text.SimpleDateFormat;
    import java.text.DateFormatSymbols;

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

## Result:

The above code sample will produce the following result.

    weekday = Monday
    weekday = Tuesday
    weekday = Wednesday
    weekday = Thursday
    weekday = Friday

Advertisement

Online Image Processing

Indian Baby Names