Java Date Time - 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;
/*ww w  .  j  a  v  a2 s.co  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.