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?
I
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.