tl;dr
LocalDate.now().get( IsoFields.WEEK_OF_WEEK_BASED_YEAR )
February 9, 2021 is in week # 6 of the ISO 8601 week-based year of 2021 that runs from Monday January 4, 2021 through Sunday January 2, 2022 (inclusive).
In standard notation, Feb 9, 2021 is the second day Tuesday of the sixth week of the week-based year 2021:
2021-W06-2
Details
The terrible class GregorianCalendar
was supplanted years ago by the modern java.time classes defined in JSR 310.
java.time
Get current date.
LocalDate today = LocalDate.now( ZoneId.of( "Asia/Kolkata" ) ) ;
Get the week of a week-based year, using the definition of ISO 8601. In this definition:
- a week runs Monday-Sunday, and
- week # 1 contains the first Thursday of the calendar-year.
As a consequence of that definition, each week-based year has either 52 or
53 whole weeks.
int week = today.get ( IsoFields.WEEK_OF_WEEK_BASED_YEAR );
And get the year number of the week-based year for that date. This may differ from the calendar year number in the first and last weeks.
int weekYear = now.get ( IsoFields.WEEK_BASED_YEAR );
For example, the ISO 8601 week-based year for 2021 started January 4, 2021. February 9, 2021 is in week # 6.
See this list of weeks in ISO 8601 week-based year of 2021.