calendar.setFirstDayOfWeek(Calendar.MONDAY); //sets first day to monday, for example.
在您的情况下,您可能需要执行以下 *** 作:
public int getWeeksOfMonth(int year, int month, int weekStart) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, month-1); calendar.set(Calendar.YEAR, year); calendar.setFirstDayOfWeek(weekStart); int numOfWeeksInMonth = calendar.getActualMaximum(Calendar.WEEK_OF_MONTH); return numOfWeeksInMonth;}
并用诸如
int weeks = getWeeksOfMonth(2012, 5, Calendar.WEDNESDAY);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)