常用API-4
Calendar 日历类
import java.util.Calendar;
public class Calendar_ {
public static void main(String[] args) {
//获取Calendar对象, getInstance方法以多态的形式,返回子类的对象
Calendar instance = Calendar.getInstance();
// System.out.println(instance);
//public int get(int field) 根据你给的日历.属性返回int值
int year = instance.get(Calendar.YEAR);//属性是静态的,用(类名.属性)获得
int month = instance.get(Calendar.MONTH)+1;//月份以"0"开始,所以要加1
int date = instance.get(Calendar.DATE);
System.out.println(year+"年"+month+"月"+date+"日");
}
}
标签:常用,get,int,instance,API,Calendar,public
From: https://www.cnblogs.com/lg369/p/17114682.html