想获取系统当前时间

 

想获取系统当前时间,用Calendar,如下:

Calendar date = Calendar.getInstance();

会自动获取系统的当前日期时间。

要获得当前的年,月,日对应的整数,如下:

int day = date.get(Calendar.DAY_OF_MONTH);

int month = date.get(Calendar.MONTH);

int year = date.get(Calendar.YEAR);

得到的结果为什么是 day=5,month=2,year=1

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章