Question: For Example I have the date: "23/2/2010" (23th Feb 2010). I want to pass it to a function which would return the **day of week**. How can I do this?

In this example, the function should return `String` "Tue".

Additionally, if just the day ordinal is desired, how can that be retrieved?

Answer: 
For **Java 8 or Later**, **Localdate** is preferable

```
import java.time.LocalDate;

public static String findDay(int month, int day, int year) {

    LocalDate localDate = LocalDate.of(year, month, day);

    java.time.DayOfWeek dayOfWeek = localDate.getDayOfWeek();
    System.out.println(dayOfWeek);

    return dayOfWeek.toString();
}

```

**Note :** if input is String/User defined, then you should parse it into **int**.
You can use below method to get Day of the Week by passing a specific date,

**Here for the set method of Calendar class, Tricky part is the index for the month parameter will starts from 0**.

```
public static String getDay(int day, int month, int year) {

        Calendar cal = Calendar.getInstance();

        if(month==1){
            cal.set(year,0,day);
        }else{
            cal.set(year,month-1,day);
        }

        int dow = cal.get(Calendar.DAY_OF_WEEK);

        switch (dow) {
        case 1:
            return "SUNDAY";
        case 2:
            return "MONDAY";
        case 3:
            return "TUESDAY";
        case 4:
            return "WEDNESDAY";
        case 5:
            return "THURSDAY";
        case 6:
            return "FRIDAY";
        case 7:
            return "SATURDAY";
        default:
            System.out.println("GO To Hell....");
        }

        return null;
    }

```