获取当前时间的年月日时分秒


1 Calendar now = Calendar.getInstance();
2         System.out.println("年: " + now.get(Calendar.YEAR));
3         System.out.println("月: " + (now.get(Calendar.MONTH) + 1) + "");
4         System.out.println("日: " + now.get(Calendar.DAY_OF_MONTH));
5         System.out.println("时: " + now.get(Calendar.HOUR_OF_DAY));
6         System.out.println("分: " + now.get(Calendar.MINUTE));
7         System.out.println("秒: " + now.get(Calendar.SECOND));
8         System.out.println("当前时间毫秒数:" + now.getTimeInMillis());
9         System.out.println(now.getTime());

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM