.getWeekYear()
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 contributor
Contribute to Docs
- 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.
Learn Java on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Java
Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.Beginner Friendly16 hours