墨染丶

导航

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

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());

 

posted on 2020-06-05 17:54  墨染丶  阅读(6914)  评论(0编辑  收藏  举报