使用Calendar调用时间 月份不对
import java.util.Calendar;
public class Test8 {
public static void main(String[] args) {
Calendar c=Calendar.getInstance();//创建Calendar对象
int year=c.get(Calendar.YEAR);//获取年
int month=c.get(Calendar.MONTH);
int day=c.get(Calendar.DAY_OF_MONTH);
int hour=c.get(Calendar.HOUR_OF_DAY);
int minute=c.get(Calendar.MINUTE);
int second=c.get(Calendar.MINUTE);
System.out.println("当前时间:"+year+"-"+month+"-"+day+"\t"+hour+":"+minute+":"+second);
}
}
输出结果:当前时间:2017-1-4 21:58:58