Java tutorial
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static int getYear(String sDate) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Date d = null; try { d = df.parse(sDate); } catch (ParseException e) { e.printStackTrace(); } if (d == null) { return 1971; } return d.getYear() + 1900; } }