Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static int getYear() { Calendar calendar = Calendar.getInstance(); SimpleDateFormat yearSdf = new SimpleDateFormat("yyyy"); String yearString = yearSdf.format(calendar.getTime()); return Integer.parseInt(yearString); } }