Here you can find the source of getYear()
public static int getYear()
//package com.java2s; //License from project: LGPL import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static int getYear() { GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(getDate());/*from w w w . j a v a 2 s .co m*/ return calendar.get(Calendar.YEAR); } public static Date getDate() { return new Date(); } public static Date getDate(long millis) { return new Date(millis); } public static String getDate(String format) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }