Java examples for java.util:Year
Get current year by yyyy
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static void main(String[] argv) throws Exception { System.out.println(year()); }//from w w w .j a va2s .c o m public static String year() { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); return sdf.format(cal.getTime()); } }