Java 获取 一个月有多少周
程序员文章站
2022-03-04 09:28:38
...
Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, 2013); c.set(Calendar.MONTH, (4 - 1)); c.setFirstDayOfWeek(Calendar.MONDAY); System.out.println( c.get(Calendar.YEAR) + "年" + (c.get(Calendar.MONTH) + 1) + "月"); System.out.println("天数:" + c.getActualMaximum(Calendar.DAY_OF_MONTH)); System.out.println("Actual周数:" + c.getActualMaximum(Calendar.WEEK_OF_MONTH)); System.out.println("Max周数:" + c.getMaximum(Calendar.WEEK_OF_MONTH));