Here you can find the source of getYear()
public static int getYear()
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int getYear() { return getYear(now()); }/*w w w .j a v a 2 s. c o m*/ public static int getYear(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar.get(Calendar.YEAR); } /** * @return the current moment */ public static Date now() { return new Date(); } }