getWeekYear(): This method is available in java.util.Calendar class of Java.
Syntax:
int java.util.Calendar.getWeekYear()
This method returns the week year represented by this Calendar.
Parameters: NA
Returns: the week year of this Calendar.
Throws:
UnsupportedOperationException - if any week year numbering isn't supported in this Calendar.
Approach
Java
import java.util.Calendar;public class CalendargetWeekYear {public static void main(String[] args) {// create a calendarCalendar calendar = Calendar.getInstance();calendar.add(Calendar.DATE, 2);System.out.println(calendar.getWeekYear());}}
Output:
2022
No comments:
Post a Comment