Something is not right with my code.
ArrayList<DayEntry> month = new ArrayList<DayEntry>();
int now_month = 9;
while(days.hasNext()) {
Map<String,Object> row = days.next();
Date in = (Date) row.get(DayType.DATE);
GregorianCalendar date = new GregorianCalendar();
date.setTime(in);
if(date.get(Calendar.MONTH) == now_month) {
String entry = (String) row.get(DayType.ENTRY);
month.add(new DayEntry(entry,date));
}
}
I first thought there was something up with my previous code regarding the days iterator, but on close inspection it appears there is something up with the GregorianCalendar...
System.out.println(in) prints ....
Wed Sep 27 15:09:58 GMT 2006
System.out.println(date.getTime()) prints .....
Wed Sep 27 15:09:58 GMT 2006
BUT, System.out.println(date.get(Calendar.MONTH)) print ....
8
and i am pretty sure Sep is the 9th month of the year.
Thanks