Here you can find the source of getCurrentMonth()
public static int getCurrentMonth()
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main{ /** /*from www.jav a 2 s .com*/ * Gets the month element from today date. * <br> * Internally calls {@link #getMonthFromDate(Date)} * <br> * E.g., * <pre> * getCurrentMonth() = 10 * //where today date is Oct 09 12:04:47 * </pre> * * @return int -the date/day from today. * */ public static int getCurrentMonth() { return getMonthFromDate(new Date()); } /** * Gets the month element from given {@link Date} object. * * @param date -{@link Date} object. * @return int -the month from given date. * @throws NullPointerException if any of the parameters is null. */ public static int getMonthFromDate(Date date) { if (StringUtils.isNull(date)) { throw new NullPointerException("date cannot be null"); } Calendar calendar = Calendar.getInstance(); if (date != null) { calendar.setTime(date); } return calendar.get(Calendar.MONTH) + 1; } }