Here you can find the source of getDaysOfYear(int year)
Parameter | Description |
---|---|
year | a parameter |
public static int getDaysOfYear(int year)
//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; } }