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
the fastest way is: Very important to set properly the Calendar depending from where are you from, because of numbering of weeks is determined to given standards. For example in Europ is ISO 8061. It means that 1 week of the year beginn when 01.01.RRRR is Thursday or further, and week beginns from Monday.
GregorianCalendar gregorianCalendar = new GregorianCalendar(year,12,31);
gregorianCalendar.setFirstDayOfWeek(Calendar.MONDAY); // week beginn from Monday
gregorianCalendar.setMinimalDaysInFirstWeek(4); // 1week mininum from Thursday
int totalWeeks = gregorianCalendar.getMaximum(Calendar.WEEK_OF_YEAR);