Java Day of Week dayOfWeek(int year, int month, int day)

Here you can find the source of dayOfWeek(int year, int month, int day)

Description

Day of week.

License

Open Source License

Parameter

Parameter Description
year a parameter
month a parameter
day a parameter

Declaration

public static int dayOfWeek(int year, int month, int day) 

Method Source Code

//package com.java2s;

public class Main {
    /**// w  w w . j a va 2 s  .  c o  m
     * Day of week. Mon Tue ... Sun : 1 2 ... 7
     *
     * @param year
     * @param month
     * @param day
     * @return
     */
    public static int dayOfWeek(int year, int month, int day) {
        if (month == 1 || month == 2) {
            month += 12;
            year--;
        }
        return (day + 2 * month + 3 * (month + 1) / 5 + year + year / 4 - year / 100 + year / 400) % 7 + 1;
    }
}

Related

  1. DayOfTheWeek(Date dt)
  2. dayOfWeek(Date date)
  3. dayOfWeek(Date inDate, TimeZone timeZone)
  4. dayOfWeek(Date time)
  5. dayOfWeek(int dayMark)
  6. dayOfWeekFromInt(final int theDay)
  7. dayOfWeekFromInteger(String aDay, boolean longName)
  8. dayOfWeekNames()
  9. endOfWeek(Date inDate, TimeZone timeZone)