Why does calendar.WEEK_OF_YEAR prints 3 instead of 6.
GregorianCalendar calendar = new GregorianCalendar();
System.out.println("time"+calendar.getTime());
System.out.println("week of year "+calendar.WEEK_OF_YEAR);
Output
time Tue Feb 09 12:58:02 IST 2021
week of year 3

calendar.WEEK_OF_YEARis a constant, you don't use it like that.You probably meant
calendar.get(Calendar.WEEK_OF_YEAR)(and, today February the 9th it will print 7, not 6, because it's 1-based, not 0-based).Note that, as the nice answer from Basil Bourque explains, you should use the new DateTime API.