Here you can find the source of day2doy(int year, int month, int mday)
Parameter | Description |
---|---|
year | Year. |
month | Month. |
mday | Day of month. |
public static int day2doy(int year, int month, int mday)
//package com.java2s; //License from project: Apache License public class Main { /** Convert Day of Month to Day of Year. * @param year Year./*from w ww. jav a 2 s . c o m*/ * @param month Month. * @param mday Day of month. * @return Day of year. */ public static int day2doy(int year, int month, int mday) { int[] regu_month_day = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; int[] leap_month_day = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }; int yday = 0; // check for leap year if ((year % 4) == 0) { yday = leap_month_day[month - 1] + mday; } else { yday = regu_month_day[month - 1] + mday; } return yday; } }