Java Day Name getDayName()

Here you can find the source of getDayName()

Description

Get the full name of the current day

License

LGPL

Return

The full name of the current day

Declaration

public static String getDayName() 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.Calendar;

public class Main {
    /**/*from w w  w. j  a v  a 2  s  . co  m*/
     * Get the full name of the current day
     * @return The full name of the current day
     */
    public static String getDayName() {
        Calendar cal = Calendar.getInstance();
        int day = cal.get(Calendar.DAY_OF_WEEK);
        String strDay;
        switch (day) {
        case Calendar.SUNDAY:
            strDay = "Sunday";
            break;

        case Calendar.MONDAY:
            strDay = "Monday";
            break;

        case Calendar.TUESDAY:
            strDay = "Tuesday";
            break;

        case Calendar.WEDNESDAY:
            strDay = "Wednesday";
            break;

        case Calendar.THURSDAY:
            strDay = "Thursday";
            break;

        case Calendar.FRIDAY:
            strDay = "Friday";
            break;

        case Calendar.SATURDAY:
            strDay = "Saturday";
            break;

        default:
            strDay = "ERROR";
            break;
        }
        return strDay;
    }
}

Related

  1. dayName(String dayNumber)
  2. dayName(String dayNumber)
  3. getCurrentDayName()
  4. getDayName(int i)
  5. getDayName(String code)
  6. getDayOfWeekName(int dayOfWeek)
  7. parseDayName(String twoLetterDayName)