Here you can find the source of month()
public static String month()
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static String month() { return now("MM"); }/*from ww w . java2s .c o m*/ public static String now(String s) { SimpleDateFormat simpledateformat = new SimpleDateFormat(s); Date date = new Date(); GregorianCalendar gregoriancalendar = new GregorianCalendar(); gregoriancalendar.setTime(date); Date date1 = gregoriancalendar.getTime(); String s1 = simpledateformat.format(date1); return s1; } public static String now(String s, Date date) { SimpleDateFormat simpledateformat = new SimpleDateFormat(s); String s1 = simpledateformat.format(date); return s1; } public static String now() { return now("yyyy-MM-dd HH:mm:ss"); } }