Can any body elaborate, how to get maximum number of weeks in a month given Calendar instance? For example in December 2007, if the first day of week is set to Calendar.SATURDAY, then total weeks should be 6. And it should be 5 in case the first day of week is set to Calendar.MONDAY.
The getMaximum(Calendar.WEEK_OF_MONTH) always returns 6; and getMinimum(Calendar.WEEK_OF_MONTH) always returns 0.
Joined: Feb 05, 2003
You don't want the getMaximum method, which will allways return 6. Instead you want the getActualMaximum method, which works based on the given calendar. Furthermore, the value will depend on the minimalDaysInFirstWeek, which I think by default is 4.
This said, both for saturdag as monday as start days of the week you will get 5 as result (with default minimalDaysInFirstWeek).