import java.text.SimpleDateFormat;
import java.util.Calendar;
public class CalendarIntroTest {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1; // 0代表1月,11代表12月
int day = cal.get(Calendar.DAY_OF_MONTH);
int hour = cal.get(Calendar.HOUR);
int minute = cal.get(Calendar.MINUTE);
int second = cal.get(Calendar.SECOND);
// 打印年月日,时分秒
System.out.format("%d/%d/%d %d:%d:%d\n",year,month,day,hour,minute,second);
// 2013/10/20 2:4:41
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
String currentTime = sdf.format(cal.getTime());
System.out.println(currentTime);
// 10/20/2013
}
}