This is real easy in Java:
private DayOfWeek getDayOfWeek(int year, int month, int day) {
return LocalDate.of(year, month, day).getDayOfWeek();
}
@Test
public void getDayOfWeekTest() {
assertEquals(DayOfWeek.FRIDAY, getDayOfWeek(2016, 3, 25));
}
It's a built-in function in Java 8. Under the hood, one can see what it's doing is converting the given date to an `EpochDay`, taking the `floorMod` of that by 7, and then returning the index of the DayOfWeek enum. Basically: public enum DayOfWeek { MONDAY, TUESDAY... }
int dow0 = (int)Math.floorMod(toEpochDay() + 3, 7);
return ENUMS[dayOfWeek - 1];