This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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.
Please help.
bart zagers
Ranch Hand
Joined: Feb 05, 2003
Posts: 234
posted
0
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).