Open In App

WeekFields weekOfWeekBasedYear() method in Java with Examples

Last Updated : 29 Jan, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
The weekOfWeekBasedYear() method of WeekFields class is used to return a field to access the week of a week-based-year based on this WeekFields. Example:
  • if the 1st day of the year is a Monday, week one starts on the 1st
  • if the 2nd day of the year is a Monday, week one starts on the 2nd and the 1st is in the last week of the previous year
  • if the 4th day of the year is a Monday, week one starts on the 4th and the 1st to 3rd is in the last week of the previous year
  • if the 5th day of the year is a Monday, week two starts on the 5th and the 1st to 4th is in week one
This field can be used with any calendar system. Syntax:
public TemporalField weekOfWeekBasedYear()
Parameters: This method accepts nothing. Return value: This method returns a field providing access to the week-of-week-based-year, not null. Below programs illustrate the WeekFields.weekOfWeekBasedYear() method: Program 1:
Output:
Week of week for 2021-12-21 :52
Program 2:
Output:
Week of week for 2014-10-12 :42
References: https://docs.oracle.com/javase/10/docs/api/java/time/temporal/WeekFields.html#weekOfWeekBasedYear()

Next Article

Similar Reads