Here you can find the source of getYear(Date date, TimeZone timeZone)
public static int getYear(Date date, TimeZone timeZone)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; import java.util.TimeZone; public class Main { private static final SimpleDateFormat _fmtYear = new SimpleDateFormat("yyyy"); public static int getYear(Date date, TimeZone timeZone) { if (date == null) throw new IllegalArgumentException("date is required."); if (timeZone == null) timeZone = TimeZone.getDefault(); _fmtYear.setTimeZone(timeZone);//from www . j a v a 2 s . co m try { return Integer.parseInt(_fmtYear.format(date)); } catch (NumberFormatException e) { throw new IllegalStateException("Failed to format date : " + e.getMessage()); } } }