Java GregorianCalendar .getWeekYear ()

Syntax

GregorianCalendar.getWeekYear() has the following syntax.

public int getWeekYear()

Example

In the following code shows how to use GregorianCalendar.getWeekYear() method.


import java.util.GregorianCalendar;
/*from  w  ww . j  a va 2  s  . c o m*/
public class Main {

   public static void main(String[] args) {

      GregorianCalendar cal = 
              (GregorianCalendar) GregorianCalendar.getInstance();

      System.out.println(cal.getTime());
      
      System.out.println(cal.getWeekYear());

   }
}

The code above generates the following result.