Java examples for java.util:Year
get Year from Date
//package com.java2s; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static void main(String[] argv) throws Exception { Date date = new Date(); System.out.println(getYear(date)); }/* w w w .j a v a 2 s .c om*/ public static int getYear(Date date) { Calendar calendar = getCalendar(); calendar.setTime(date); return calendar.get(Calendar.YEAR); } public static Calendar getCalendar() { return GregorianCalendar.getInstance(); } }