public static int getAbsYearDay(final java.util.Date date, final int yearDay) {
        if (yearDay == 0 || yearDay < -MAX_DAYS_PER_YEAR || yearDay > MAX_DAYS_PER_YEAR) {
            throw new IllegalArgumentException(MessageFormat.format(INVALID_YEAR_DAY_MESSAGE,
                    yearDay));
        }
        if (yearDay > 0) {
            return yearDay;
        }
        final Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        final int year = cal.get(Calendar.YEAR);
        // construct a list of possible year days..
        final List<Integer> days = new ArrayList<Integer>();
        cal.set(Calendar.DAY_OF_YEAR, 1);
        while (cal.get(Calendar.YEAR) == year) {
            days.add(cal.get(Calendar.DAY_OF_YEAR));
            cal.add(Calendar.DAY_OF_YEAR, 1);
        }
        return days.get(days.size() + yearDay);
    }
public static int getAbsYearDay ( final java . util . Date date , final int yearDay ) { if ( yearDay == 0 || yearDay < - MAX_DAYS_PER_YEAR || yearDay > MAX_DAYS_PER_YEAR ) { throw new IllegalArgumentException ( MessageFormat . format ( INVALID_YEAR_DAY_MESSAGE , yearDay ) ) ; } if ( yearDay > 0 ) { return yearDay ; } final Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( date ) ; final int year = cal . get ( Calendar . YEAR ) ; final List < Integer > days = new ArrayList < Integer > ( ) ; cal . set ( Calendar . DAY_OF_YEAR , 1 ) ; while ( cal . get ( Calendar . YEAR ) == year ) { days . add ( cal . get ( Calendar . DAY_OF_YEAR ) ) ; cal . add ( Calendar . DAY_OF_YEAR , 1 ) ; } return days . get ( days . size ( ) + yearDay ) ; }
Returns the absolute year day for the year specified by the
supplied date. Note that a value of zero (0) is invalid for the
yearDay parameter and an <code>IllegalArgumentException</code>
will be thrown.
@param date a date instance representing a day of the year
@param yearDay a day of year offset
@return the absolute day of month for the specified offset