Here you can find the source of getMonth(String dateTime)
@SuppressWarnings("static-access") public static int getMonth(String dateTime)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { @SuppressWarnings("static-access") public static int getMonth(String dateTime) { Calendar c = Calendar.getInstance(); c.setTime(getDateTime(dateTime)); int month = c.get(c.MONTH) + 1; return month; }// w ww .j ava 2 s. co m public static Timestamp getDateTime() { return Timestamp.valueOf(getFormatDate("yyyy-MM-dd HH:mm:ss")); } public static Timestamp getDateTime(String datetime) { return Timestamp.valueOf(datetime); } protected static String getFormatDate(String formatString) { String currentDate = ""; SimpleDateFormat format1 = new SimpleDateFormat(formatString); currentDate = format1.format(new Date()); return currentDate; } }