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());
  }//from  ww w .j a  v a  2  s .  com

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

Related Exercise