Here you can find the source of getMonth(String startTime)
public static int getMonth(String startTime)
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static int getMonth(String startTime) { int year = 0; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); try {/*from ww w. j a v a2s.c om*/ year = sdf.parse(startTime).getMonth() + 1; } catch (Exception ex) { ex.printStackTrace(); } return year; } }