总结:时间类Calendar.类代表当前时

Calendar c=Calendar.getInstance();,,Calendar是抽象类。Calendar的构造方法是私有的,API提供了getIntstance方法来创建的对象,

使用该方法获得的Date对象就代表当前系统时间,

package com.aaaaaaaaaaaaaaaaaaaa;

import java.util.*;

public class time {

	public static void main(String[] args) {
		Calendar c = Calendar.getInstance();
		int year = c.get(Calendar.YEAR);
		int month = c.get(Calendar.MONTH) + 1;
		int date = c.get(Calendar.DATE);
		int hour = c.get(Calendar.HOUR_OF_DAY);
		int second = c.get(Calendar.SECOND);
		int minute = c.get(Calendar.MINUTE);
		System.out.println("年份:" + year);
		System.out.println("月份:" + month);
		System.out.println("日期" + date);
		System.out.println("小时:" + hour);
		System.out.println("分钟:" + minute);
		System.out.println("秒" + second);

	}

}



年份:2013
月份:11
日期30
小时:8
分钟:39
秒51

  

 

 

 

 

 

相关文章:

  • 2022-01-11
  • 2021-07-25
  • 2022-02-08
  • 2022-01-22
  • 2021-12-21
  • 2022-12-23
猜你喜欢
  • 2021-06-14
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-11-04
相关资源
相似解决方案