1 获取当前时间 时分秒

        // 获取当前时分秒
        Calendar now = Calendar.getInstance();
        int is = now.get(Calendar.HOUR_OF_DAY);
        int isf = now.get(Calendar.MINUTE);
        int iss = now.get(Calendar.SECOND);

 2 获取当前年月日

        // 获取当前年份、月份、日期  
        Calendar cale = null;  
        cale = Calendar.getInstance();  
        int year = cale.get(Calendar.YEAR);  
        int month = cale.get(Calendar.MONTH) + 1;  
        int day = cale.get(Calendar.DATE);  
        System.out.println("Year年: " + year);  
        System.out.println("Month月: " + month);  
        System.out.println("Day日: " + day);

 

相关文章:

  • 2022-12-23
  • 2021-12-21
  • 2022-01-05
  • 2021-12-10
猜你喜欢
  • 2021-06-13
  • 2021-12-20
  • 2021-10-06
  • 2021-06-17
  • 2022-12-23
相关资源
相似解决方案