Here you can find the source of getYear(String dateTime)
@SuppressWarnings("static-access") public static int getYear(String dateTime)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { @SuppressWarnings("static-access") public static int getYear(String dateTime) { Calendar c = Calendar.getInstance(); c.setTime(getDateTime(dateTime)); int year = c.get(c.YEAR); return year; }//from w ww.j a va 2 s . co m public static Timestamp getDateTime() { return Timestamp.valueOf(getFormatDate("yyyy-MM-dd HH:mm:ss")); } public static Timestamp getDateTime(String datetime) { return Timestamp.valueOf(datetime); } protected static String getFormatDate(String formatString) { String currentDate = ""; SimpleDateFormat format1 = new SimpleDateFormat(formatString); currentDate = format1.format(new Date()); return currentDate; } }