Java Utililty Methods Day Of Year

List of utility methods to do Day Of Year

Description

The list of methods to do Day Of Year are organized into topic(s).

Method

StringcurrentYearMonthDay()
current Year Month Day
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd");
return sdf.format(new Date().getTime());
booleandateOfYearBetween(final int month, final int dayOfMonth, final int fromMonth, final int fromDayOfMonth, final int toMonth, final int toDayOfMonth)
date Of Year Between
if (fromMonth == toMonth) {
    if (month != fromMonth) {
        return false;
    if (dayOfMonth < fromDayOfMonth || dayOfMonth > toDayOfMonth) {
        return false;
} else if (fromMonth < toMonth) {
...
intdayOfYear(final int year, final int month, final int day)
day Of Year
int day_of_year;
if (isLeapYear(year)) {
    day_of_year = 275 * month / 9 - (month + 9) / 12 + day - 30;
} else {
    day_of_year = 275 * month / 9 - ((month + 9) / 12 << 1) + day - 30;
return day_of_year;
intdayOfYear(int month, int day, int year)
return the day of year for the month and day, for the given year
return day + dayOffset[isLeapYear(year) ? 1 : 0][month];
intdayOfYear(int year, int month, int date)
the day of the year in [0-365] of the given date.
int leapAdjust = month > 2 && isLeapYear(year) ? 1 : 0;
return MONTH_START_TO_DOY[month - 1] + leapAdjust + date - 1;
intdayOfYear(int year, int month, int day)
Gets day number in year
int K = (isLeapYear(year)) ? 1 : 2;
int N = (int) ((int) ((275 * month) / 9) - K * (int) ((month + 9) / 12) + day - 30);
return N;
intdayOfYear(int year, int month, int day)
Day of year.
return DAYS_OF_YEAR_PER_MONTH[month - 1] + day + (month >= 3 && isLeapYear(year) ? 1 : 0);
intdaysInPriorYears(final int y)
Return the number of days in the years from 0 AD to December 31th of the given year.
return 365 * y 
        + y / 4 
        - y / 100 
        + y / 400;
intdaysInPriorYears(int yr)
Return the number of days in prior years since 1601
if (yr < 1601) {
    throw new IllegalArgumentException("'year' must be 1601 or greater");
int y = yr - 1601;
int days = 365 * y 
        + y / 4 
        - y / 100 
        + y / 400; 
...
intdaysInPriorYears(int yr, boolean use1904windowing)
Return the number of days in prior years since 1900
if ((!use1904windowing && yr < 1900) || (use1904windowing && yr < 1900)) {
    throw new IllegalArgumentException("'year' must be 1900 or greater");
int yr1 = yr - 1;
int leapDays = yr1 / 4 
        - yr1 / 100 
        + yr1 / 400 
        - 460; 
...