Here you can find the source of getYear(Date date)
Parameter | Description |
---|---|
date | The full date |
public static int getYear(Date date)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**//from w w w .ja v a 2 s. c o m * Retrieve a year of a full date * * @param date * The full date * @return int - The year of the date */ public static int getYear(Date date) { Calendar calendar = new GregorianCalendar(); calendar.setTime(date); int year = calendar.get(Calendar.YEAR); return year; } }