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 getMonth(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 0; } return d.getMonth(); } }