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

intdaysInYear(int yearInteger)
Answer number of days in given year, accounting for leap yearsTo.
return 365 + leapYearBalance(yearInteger);
Stringfirstdayofyear()
firstdayofyear
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
String year = sdf.format(new java.util.Date());
return year + "-01-01";
intgetDayFromYear(String year)
get Day From Year
SimpleDateFormat format = new SimpleDateFormat(year_format);
Date date;
int day = 0;
try {
    date = format.parse(year);
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    day = calendar.getActualMaximum(Calendar.DAY_OF_YEAR);
...
intgetDaysInYear(final int year)
Returns the number of days in the year
if (isLeapYear(year)) {
    return DAYS_PER_YEAR + 1;
return DAYS_PER_YEAR;
intgetDaysInYear(int year)
get Days In Year
return ((year % 4) == 0) ? 366 : 365;
intgetDaysInYear(int year)
get Days In Year
if (year > 1582) {
    if (year % 400 == 0)
        return 366;
    else if (year % 100 == 0)
        return 365;
    else if (year % 4 == 0)
        return 366;
    else
...
intgetDaysOfYear(int year)
get Days Of Year
if (isBissextile(year)) {
    return 366;
return 365;
longgetEndTimeOfYear(int year)
get End Time Of Year
Calendar cal = Calendar.getInstance();
cal.set(year + 1, Calendar.JANUARY, 1, 23, 59, 59);
return cal.getTimeInMillis() - 24 * 60 * 60 * 1000;
DategetFirstDayOfTheYear(int year)
get First Day Of The Year
Calendar firstDayOfThisYear = Calendar.getInstance();
firstDayOfThisYear.clear();
firstDayOfThisYear.set(Calendar.YEAR, year);
firstDayOfThisYear.set(Calendar.DAY_OF_YEAR, 1);
return firstDayOfThisYear.getTime();
DategetFirstDayOfYear(int year)
get First Day Of Year
return getFirstDayOfQuarter(year, 1);