Java Program to Write Display Weekday

bookmark

import java.text.SimpleDateFormat;
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
    //create an object of SimpleDateFormat as ‘s’ with the argument as ‘EEEE’.
    SimpleDateFormat s = new SimpleDateFormat("EEEE");
    // Declare a string variable as ‘month’ 
    //and initialize it to the current date and time 
    //using an inbuild method of SimpleDateFormat as s.format(new Date())
    String day= s.format(new Date());
    //Print the result in fullform
    System.out.println("Weekday in fullform is "+day);
    }
}

 


Output:

Weekday in full form is Friday