calculate number of weeks in a given year

前端 未结 9 2189
北恋
北恋 2020-12-04 01:48

I would like to get the number of weeks in any given year. Even though 52 is accepted as a generalised worldwide answer, the calendars for 2015,

9条回答
  •  -上瘾入骨i
    2020-12-04 02:16

        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, 2015);
        cal.set(Calendar.MONTH, Calendar.DECEMBER);
        cal.set(Calendar.DAY_OF_MONTH, 31);
        System.out.println(cal.get(Calendar.WEEK_OF_YEAR));
    

提交回复
热议问题