.getWeekYear()
Anonymous contributor
Anonymous contributor1 total contribution
Anonymous contributor
Published Sep 12, 2023
Contribute to Docs
The .getWeekYear()
method of the Calendar
class returns the time represented by a Calendar
object in the form of the week year.
Syntax
calendar.getWeekYear()
Returns the week year represented by this Calendar
object in as an integer
.
Example
This example code shows the basic use of the .getWeekYear()
method:
import java.util.Calendar;// CalendarGetWeekYearExample.javapublic class CalendarGetWeekYearExample{public static void main(String[] args) {// Create a Calendar instanceCalendar calendar = Calendar.getInstance();// Get the current time in weekyearlong currentWeekYear = calendar.getWeekYear();// Prints current time in week yearSystem.out.println("Current Week Year: " + currentWeekYear);}}
The output should be similar to:
Current Week Year: 2023
All contributors
- Anonymous contributorAnonymous contributor1 total contribution
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.