(1)Calendar是日历类,它可以获取任意指定日历值,然后自由组合。
Calendar是抽象类不能实例化,但是他提供了获取其实例的方法
Calendar c = Calendar.getInstance();// 多态
(2)成员方法:
get(日历字段):根据给定的日历字段获取值
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int date = c.get(Calendar.DATE);
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
String s = year + "年" + (month + 1) + "月" + date + "日" + " " + hour
+ ":" + minute + ":" + ((second>9)?second:"0"+second);