Here you can find the source of getYear()
public static String getYear()
//package com.java2s; import java.util.Calendar; public class Main { public static String getYear() { Calendar CD = Calendar.getInstance(); int YY = CD.get(Calendar.YEAR); StringBuffer curDateString = new StringBuffer(); curDateString.append(YY);//w w w. jav a 2 s.co m return curDateString.toString(); } }