Here you can find the source of getYear()
public static int getYear()
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static int getYear() { Calendar calendar = new GregorianCalendar(); Date trialTime = new Date(); calendar.setTime(trialTime);/* w w w . jav a 2 s. c o m*/ return calendar.get(Calendar.YEAR); } public static int getYear(Date date) { Calendar calendar = new GregorianCalendar(); calendar.setTime(date); return calendar.get(Calendar.YEAR); } }