import java.text.SimpleDateFormat;
import java.util.Date;/**from 时代Java - N o w J a v a . c o m**/
public class Main {
public static void main(String[] args) {
Date date = new Date();
//formatting month in M format like 1,2 etc
String strDateFormat = "M";
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
System.out.println("Current Month in M format : " + sdf.format(date));
//formatting Month in MM format like 01, 02 etc.//来 自 时代Java - N o w J a v a . c o m
strDateFormat = "MM";
sdf = new SimpleDateFormat(strDateFormat);
System.out.println("Current Month in MM format : " + sdf.format(date));
//formatting Month in MMM format like Jan, Feb etc.
strDateFormat = "MMM";
sdf = new SimpleDateFormat(strDateFormat);
System.out.println("Current Month in MMM format : " + sdf.format(date));
/**代码未完, 请加载全部代码(NowJava.com).**/