欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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));

 

相关标签: java