I want to get the number of day.. i.e. Jan 1 is day 1 jan 2 is day 2 Feb 1 is day 32 and december 31 is day 365 or 366 depending on leap year or not
i have used all kind of techniques such as date1 - date2 etc... but nothing seems to work for me cant get the logic right may be.. what i want is count and add the number of the months that has gone past plus the number days of the running month i.e today is 21st Sept 2012 is day number (31(jan)+29(feb)+31(mar)+30(apr)+31(may)+30(june)+31(july)+31(aug)+20(sept)) = 264th day and they will keep adding plus one every time a day go past... thanks
mycode
int year = Calendar.getInstance().get(Calendar.YEAR);
GregorianCalendar gc = new GregorianCalendar();
gc.set(GregorianCalendar.DAY_OF_MONTH, 8);
gc.set(GregorianCalendar.MONTH, GregorianCalendar.JUNE);
gc.set(GregorianCalendar.YEAR, year);
int numberofDaysPassed=gc.get(GregorianCalendar.DAY_OF_YEAR);
numberofDaysPassed is giving me 160, undesired result