import java.util.Date;
import java.text.DateFormat;
/**
* 格式化时间类
* DateFormat.FULL = 0
* DateFormat.DEFAULT = 2
* DateFormat.LONG = 1
* DateFormat.MEDIUM = 2
* DateFormat.SHORT = 3
* @author Michael
* @version 1.0, 2007/03/09
*/
public class Test{}
}
补充一下:
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
System.out.println("System Date: " + cal.get(Calendar.MONTH+1));
注意下,月份是从0开始的,要Calendar.MONTH+1才可以的