How to Get the Day Name From Date In Java

We can make use of the java.time.format.TextStyle class to get the day name from date in Java 8 and above.


Example:

package org.code2care.examples;

import java.time.LocalDate;
import java.time.format.TextStyle;
import java.util.Locale;

public class DayFromDateJava {

    public static void main(String[] args) {

        LocalDate date = LocalDate.now();
        String dayName = date.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.ENGLISH);
        System.out.println("The day of the date is : " + dayName);
    }
}
Output:

The day of the date is : Wednesday


Some examples of options for TextStyle and Locale to choose from.

TextStyle OptionOutput Example (English Locale)
FULLMonday
FULL_STANDALONEMonday
SHORTMon
SHORT_STANDALONEMon
NARROWM
NARROW_STANDALONEM


Locale OptionOutput Example (Day Name in English)
Locale.ENGLISHMonday
Locale.FRENCHlundi
Locale.GERMANMontag
Locale.ITALIANlunedì
Locale.JAPANESE月曜日
Locale.CHINESE星期一

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!