If all you want is the day-of-year, why don'you just use GregorianCalendars DAY_OF_YEAR
field?
import java.util.GregorianCalendar;
public class CalTest {
public static void main(String[] argv) {
GregorianCalendar gc = new GregorianCalendar();
gc.set(GregorianCalendar.DAY_OF_MONTH, 8);
gc.set(GregorianCalendar.MONTH, GregorianCalendar.JUNE);
gc.set(GregorianCalendar.YEAR, 2010);
System.out.println(gc.get(GregorianCalendar.DAY_OF_YEAR));
}
}
Alternatively, you could calculate the difference between today's Julian date and that of Jan 1st of this year. But be sure to add 1 to the result, since Jan 1st is not the zeroth day of the year:
int[] now = {2010, 6, 8};
int[] janFirst = {2010, 1, 1};
double dayOfYear = toJulian(now) - toJulian(janFirst) + 1
System.out.println(Double.valueOf(dayOfYear).intValue());