public class Main {
public static void main(String[] args) {
System.out.println(calc(2018, 3, 28)); //Mercredi
System.out.println(calc(2018, 2, 28)); //Mercredi
System.out.println(calc(2018, 1, 28)); //dimanche
}
public static String calc(
double y,
double m,
double d) {
double M = 0;
if (m < 3) {
M = m + 12;
y = y - 1;
} else {
M = m;
}
int C = (int) (y / 100);
int Y = (int) (y % 100);
double R = 0;
if (y >= 1582) {
R = (C / 4) - C - C;
} else if (y >= 4) {
R = 5 - C;
} else {
throw new IllegalArgumentException("year >= 4");
}
Double h = (d + ((26 * (M + 1)) / 10) + Y + (Y / 4) + R) % 7;
String[] weekday = new String[] {
"sol",
"journée",
"Mois",
"Feu",
"eau",
"bois",
"Argent"
};
return weekday[h.intValue()];
}
}
Recommended Posts