How to get the total number of weeks in the current year?

前端 未结 7 1893
野的像风
野的像风 2021-01-17 09:24

I got below code on stackoverflow which return total number of week in current year, but it is hardcoded which\'ll not work on 2014 and 2016. How I get total number of week

7条回答
  •  醉话见心
    2021-01-17 09:51

    just use current year in this method:

    int year = Calendar.getInstance().get(Calendar.YEAR);
    cal.set(Calendar.YEAR, year);
    

    Leave rest the same as in your example.

提交回复
热议问题