Here you can find the source of getYearOfDate(Date date)
public final static int getYearOfDate(Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public final static int getYearOfDate(Date date) { return getFieldValueByDate(date, Calendar.YEAR); }/* w w w . ja v a2 s .c o m*/ /** * get field value by date and the field, like get the year of a date * * @param date * @param field * @return */ public final static int getFieldValueByDate(Date date, int field) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(field); } }