You are viewing a single comment's thread. Return to all comments →
It's more fun not to use the date APIs at all :)
private static final String[] DAYS = {"SUNDAY", "MONDAY","TUESDAY", "WEDNESDAY", "THURSDAY","FRIDAY","SATURDAY"}; public static void main(String[] args) { Scanner in = new Scanner(System.in); int month = in.nextInt(); int day = in.nextInt(); int year = in.nextInt(); day += ((month < 3) ? year-- : (year - 2)); int dayOfWeek = ((((23 * month) / 9) + day + 4 + (year / 4)) - (year / 100) + (year / 400)) % 7; System.out.println(DAYS[dayOfWeek]); }
Java Date and Time
You are viewing a single comment's thread. Return to all comments →
It's more fun not to use the date APIs at all :)