code: public int dayOfYear(Date date) {
          GregorianCalendar calendar = new GregorianCalendar();
          calendar.setTime(date);
          return calendar.get(Calendar.DAY_OF_YEAR);
      }
docs: Get the day of the year for the given date. The day of the year is
  between 1-365 (366 for leap years). Note that if the given date is
  <code>null</code>, then a {@link NullPointerException} is thrown.
  
  @param date The date to get the day of the year from
  
  @return The day within the year for the given date