Method of Tool class
Gets the number of days for the specified month public
static int getdaysbyyearmonth (int month) {
Calendar a = Calendar.getinstance ();
A.set (Calendar.year, year);
A.set (Calendar.month, month-1);
A.set (calendar.date, 1);
A.roll (Calendar.date,-1);
int maxdate = A.get (calendar.date);
return maxdate;
}
Second, traverse
public void Dayreport (Date month) {
Calendar cal = Calendar.getinstance ();
Cal.settime (month);//month for a specified month any date
int year = Cal.get (calendar.year);
int m = Cal.get (calendar.month);
int daynumofmonth = Timeutils.getdaysbyyearmonth (year, m);
Cal.set (Calendar.day_of_month, 1);//starting from A for
(int i = 0; i < daynumofmonth i++, Cal.add (calendar.date, 1)) {
date d = cal.gettime ();
SimpleDateFormat SimpleDateFormat = new SimpleDateFormat ("Yyyy-mm-dd");
String df = Simpledateformat.format (d);
}
}