Here you can find the source of dayOfYear(int year, int month, int day)
Parameter | Description |
---|---|
year | Year |
month | Month |
day | Day |
public static int dayOfYear(int year, int month, int day)
//package com.java2s; //License from project: Apache License public class Main { /**//from ww w . ja v a 2 s . co m * Gets day number in year * * @param year Year * @param month Month * @param day Day * @return Day number in year */ public static int dayOfYear(int year, int month, int day) { int K = (isLeapYear(year)) ? 1 : 2; int N = (int) ((int) ((275 * month) / 9) - K * (int) ((month + 9) / 12) + day - 30); return N; } /** * Cheks is leap year or not * * @param year Year value * @return True if leap year, false otherwise */ public static boolean isLeapYear(int year) { if (year < 1582) { if (year % 4 == 0) return true; } if (year % 100 == 0 && (year / 100) % 4 != 0) return false; if (year % 4 == 0) return true; return false; } }