Java Day Of Year getDaysOfYear(int year)

Here you can find the source of getDaysOfYear(int year)

Description

get Days Of Year

License

Open Source License

Parameter

Parameter Description
year a parameter

Declaration

public static int getDaysOfYear(int year) 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static int getDaysOfYear(int year) {
        if (isBissextile(year)) {
            return 366;
        }//  www. ja va 2  s . c om
        return 365;
    }

    public static int getDaysOfYear(Date date) {
        if (isBissextile(date)) {
            return 366;
        }
        return 365;
    }

    public static boolean isBissextile(Date date) {
        String format = new SimpleDateFormat("yyyy").format(date);
        return isBissextile(Integer.parseInt(format));
    }

    public static boolean isBissextile(int year) {
        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            return true;
        }
        return false;
    }
}

Related

  1. firstdayofyear()
  2. getDayFromYear(String year)
  3. getDaysInYear(final int year)
  4. getDaysInYear(int year)
  5. getDaysInYear(int year)
  6. getEndTimeOfYear(int year)
  7. getFirstDayOfTheYear(int year)
  8. getFirstDayOfYear(int year)
  9. getLastYearOfToday()