Here you can find the source of getYear(Date date)
public static int getYear(Date date)
//package com.java2s; /**/* w w w . j a v a 2 s. co m*/ * Copyright (c) 2014 http://www.lushapp.wang * * Licensed under the Apache License, Version 2.0 (the "License"); */ import java.util.*; public class Main { public static int getYear(Date date) { return getDatePar(Calendar.YEAR, date); } public static int getDatePar(int par, Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int result = calendar.get(par); switch (par) { case Calendar.MONTH: result++; } return result; } }