Here you can find the source of getMonth()
public static String getMonth()
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getMonth() { Calendar c = getCurCalendar(); return "" + (c.get(Calendar.MONTH) + 1); }/*from w w w . j a v a 2 s. com*/ public static int getMonth(long time) { String date = new SimpleDateFormat("yyyyMM").format(time); return Integer.parseInt(date); } public static Calendar getCurCalendar() { return Calendar.getInstance(); } }