JAVA中的Calendar得到当前时间的年份、月份、日期
import java.util.Calendar;
public class CalendarTest {
public static void main(String[] args){
Calendar cal = Calendar.getInstance();
int day = cal.get(Calendar.DATE); //日
int month = cal.get(Calendar.MONTH) + 1; //月
int year = cal.get(Calendar.YEAR); //年
System.out.println("Date:" + cal.getTime());
System.out.println("Day:" + day);
System.out.println("Month:" + month);
System.out.println("Year:" + year);
}
}
//转载自:http://blog.sina.com.cn/s/blog_6c71e0170100lkhf.html