Here you can find the source of getMonth(String f)
public static Integer getMonth(String f)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Integer getMonth(String f) { Integer month;//from w ww. j a v a2 s . co m try { SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy"); Date dt1 = format1.parse(f); DateFormat format2 = new SimpleDateFormat("MM"); month = Integer.valueOf(format2.format(dt1)); } catch (Exception ex) { month = new Integer(-1); } return month; } }