Hi, need help as to what is the code doing, if possible each statement if anyone knows:
When it is run, when dd/mm/yyyy format is enter, it will give 20 Dec 2010 is a Monday
Why is the monthIndices and division done for ?
public static String dayOfWeek(int dd, int mm, int yyyy) {
int[] monthIndices = {1,4,4,0,2,5,0,3,6,1,4,6};
String[] dayOfWeek = {"Saturday", "Sunday", "Monday",
"Tuesday", "Wednesday", "Thursday",
"Friday"};
if ((yyyy % 4 == 0) && !(yyyy % 100 == 0) ||
(yyyy % 400 == 0)){
monthIndices[0] = 0;
monthIndices[1] = 3;
}
int yy = yyyy % 100;
int yyDiv4 = yy / 4;
int keyNumber = monthIndices[mm-1];
int sum = yy+yyDiv4+keyNumber+dd;
int adjValue = 0;
if (yyyy / 100 == 18)
adjValue = 2;
else
if (yyyy / 100 == 20)
adjValue = 6;
else
if (yyyy / 100 == 21)
adjValue = 4;
int remainder = (sum + adjValue) % 7;
String day = dayOfWeek[remainder];
return day;
}
}