Java在eclipse中输出运行日期时间

Java在eclipse中输出运行日期时间

//获取时间
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH )+1;
int day = cal.get(Calendar.DAY_OF_MONTH);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
int second = cal.get(Calendar.SECOND);
System.out.print(“重启时间”+year+“年”);
System.out.print(month+“月”);
System.out.print(day+“日”);
System.out.print(hour+“时”);
System.out.print(minute+“分”);
System.out.print(second+“秒”);
Thread.currentThread().sleep(5000);
## 运行结果
在这里插入图片描述

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页