Here you can find the source of getYear(String startTime)
public static int getYear(String startTime)
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static int getYear(String startTime) { int year = 0; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); try {/*from w ww . j ava 2s. c o m*/ year = sdf.parse(startTime).getYear() + 1900; } catch (Exception ex) { ex.printStackTrace(); } return year; } }