Here's some code I wrote years ago using a different algorithm called Zeller's Congruence[1]. The advantage of this is it doesn't require a lookup table:
public int dayOfWeek(int year, int month, int day) {
day += month < 3 ? year-- : year - 2;
return ((((23 * month) / 9) + day + 4 + (year / 4)) - (year / 100) + (year / 400)) % 7;
}
[1] https://en.wikipedia.org/wiki/Zeller%27s_congruence