I want to select records that have a created date between the first and the last day of a given month. I calculate the month with begin and enddate the following way:
The Date "month" is just a random date inside the timeframe
Calendar cal = Calendar.getInstance();
cal.setTime(month);
int endday = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
int actualmonth = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR);
Date begin = format.parse("01." + actualmonth + "." + year);
Date end = format.parse(endday + "." + actualmonth + "." + year);
When I think about this, I'd actually have to set the daytime as well, to avoid records going missing on the last day of the month.
I feel this is kinda inelegant, anyone up for a better solution?