Here you can find the source of getYear(Calendar cal)
public static String getYear(Calendar cal)
//package com.java2s; import java.util.Calendar; public class Main { public static String getYear(Calendar cal) { return String.valueOf(cal.get(Calendar.YEAR)); }//from www. j av a 2 s. c om public static int getYear(String s) { if (s == null || s.length() < 10) { return 1970; } return Integer.parseInt(s.substring(0, 4)); } }