Java - Write code to get current Year

Requirements

Write code to get current Year

Demo

import java.util.Calendar;

public class Main {
  public static void main(String[] argv) {
    System.out.println(getNowYear());
  }// w ww  . java2 s  .com

  public static int getNowYear() {
    Calendar cc = Calendar.getInstance();
    return cc.get(Calendar.YEAR);
  }
}

Related Exercise