Calendar 获取年 月 日 时 分 秒

        Calendar calendar = Calendar.getInstance();
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH) + 1;
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int minute = calendar.get(Calendar.MINUTE);
        int millisecond = calendar.get(Calendar.SECOND);
        System.out.print("运行时间:" + year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + millisecond);    

  

posted @ 2018-05-11 10:57  qukaige  阅读(2868)  评论(0编辑  收藏  举报