首页 > 代码库 > 时间输出

时间输出

  1.  /** 单独输出年月日时分秒等 */  
  2.         Calendar c = Calendar.getInstance();  
  3.         System.out.println("年: " + c.get(Calendar.YEAR));  
  4.         // 月份从0开始,加1校正  
  5.         System.out.println("月: " + (c.get(Calendar.MONTH) + 1) + "");  
  6.         System.out.println("日: " + c.get(Calendar.DAY_OF_MONTH));  
  7.         System.out.println("时: " + c.get(Calendar.HOUR_OF_DAY));  
  8.         System.out.println("分: " + c.get(Calendar.MINUTE));  
  9.         System.out.println("秒: " + c.get(Calendar.SECOND));  
  10.         System.out.println("当前时间毫秒数:" + c.getTimeInMillis());  
  11.         System.out.println("当前时间: " + c.getTime());  

时间输出