Java Day of Week dayOfWeek(int dayMark)

Here you can find the source of dayOfWeek(int dayMark)

Description

day Of Week

License

Apache License

Declaration

public static int dayOfWeek(int dayMark) 

Method Source Code

//package com.java2s;
/**//  w  w  w  .  j  a  v  a 2 s  .co m
 * Copyright 2013-present febit.org (support@febit.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * 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;
    }

    public static int dayOfWeek(int dayMark) {
        return dayOfWeek(getYearOfDayMark(dayMark), getMonthOfDayMark(dayMark), getDayOfDayMark(dayMark));
    }

    public static int getYearOfDayMark(int day) {
        return day / 10000;
    }

    public static int getMonthOfDayMark(int day) {
        return (day % 10000) / 100;
    }

    public static int getDayOfDayMark(int day) {
        return day % 100;
    }
}

Related

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