I have tried the following code, it displayed the date values for the first two times of the run, but later started throwing a nullpointerexception, any idea why this is happening?
DBCursor c=test.find();
while(c.hasNext())
{
DBObject dbc=c.next();
Date n=(Date)dbc.get("time");
System.out.println(n);
Calendar cal = new GregorianCalendar();
cal.setTime(n);
System.out.println(cal.get(Calendar.DAY_OF_MONTH));
}