Java Day Of Year daysInPriorYears(int yr)

Here you can find the source of daysInPriorYears(int yr)

Description

Return the number of days in prior years since 1601

License

Apache License

Parameter

Parameter Description
yr a year (1600 < yr < 4000)

Return

days number of days in years prior to yr.

Declaration


private static int daysInPriorYears(int yr) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from  w w w.ja v  a  2  s .co  m
     * Return the number of days in prior years since 1601
     *
     * @return    days  number of days in years prior to yr.
     * @param     yr    a year (1600 < yr < 4000)
     * @exception IllegalArgumentException if year is outside of range.
     */

    private static int daysInPriorYears(int yr) {
        if (yr < 1601) {
            throw new IllegalArgumentException("'year' must be 1601 or greater");
        }
        int y = yr - 1601;
        int days = 365 * y // days in prior years
                + y / 4 // plus julian leap days in prior years
                - y / 100 // minus prior century years
                + y / 400; // plus years divisible by 400

        return days;
    }
}

Related

  1. dayOfYear(int month, int day, int year)
  2. dayOfYear(int year, int month, int date)
  3. dayOfYear(int year, int month, int day)
  4. dayOfYear(int year, int month, int day)
  5. daysInPriorYears(final int y)
  6. daysInPriorYears(int yr, boolean use1904windowing)
  7. daysInYear(int yearInteger)
  8. firstdayofyear()
  9. getDayFromYear(String year)