• Java 日期类 Calendar


    package com.xuyigang1234.chp05.sec01;
    import java.util.Calendar;;
    public class TestCalendar {
        public static void main(String[] args) {
            Calendar cal = Calendar.getInstance();
            System.out.println("现在是:"+cal.get(Calendar.YEAR)+"年"
                    +(cal.get(Calendar.MONTH)+1)+"月"
                    +cal.get(Calendar.DAY_OF_MONTH)+"日"
                    +cal.get(Calendar.HOUR_OF_DAY)+"时"
                    +cal.get(Calendar.MINUTE)+"分"
                    +cal.get(Calendar.SECOND)+"秒");
        //今天星期几
            System.out.println(cal.get(Calendar.DAY_OF_WEEK));
            System.out.println(cal.get(Calendar.DAY_OF_MONTH));
            String[] weekDays = {"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
            System.out.println("今天是:"+weekDays[cal.get(Calendar.DAY_OF_WEEK)-1]);
            
            
        }
    }
    现在是:2018年11月22日21时43分34秒
    5
    22
    今天是:星期四
  • 相关阅读:
    STL next_permutation 全排列
    日期问题
    兰顿蚂蚁
    矩阵翻硬币
    数学问题-排列组合
    h5css3_03练习
    h5css3_03
    h5css3_02练习
    h5css3_02
    h5c3_01练习
  • 原文地址:https://www.cnblogs.com/xyg-zyx/p/10004147.html
Copyright © 2020-2023  润新知