Here you can find the source of formatYear(Date date)
public static String formatYear(Date date)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final SimpleDateFormat DEFAULT_YEAR_FORMAT = new SimpleDateFormat("yyyy"); public static String formatYear(Date date) { return format(date, DEFAULT_YEAR_FORMAT); }/*from w w w.j a v a 2 s.c o m*/ public static String format(Date date, DateFormat format) { if (date == null || format == null) { return ""; } return format.format(date); } }