date类学习【四】

import java.util.Calendar;

import java.util.GregorianCalendar;


public class TestCalendar {

        public static void main(String[] args ) {

               Calendar cal = new GregorianCalendar();   // 父类 new 子类对象

               System. out .println( " 年 :" + cal .get(Calendar. YEAR ));

               System. out .println( "MONTH: " + ( cal .get(Calendar. MONTH )+1));

               System. out .println( "DAY_OF_MONTH: " + cal .get(Calendar. DAY_OF_MONTH ));

               

                /** 请给我一个 Date 类型的对象,可以通过 setTime(Date) 方法 , 将这个时间设置到日历 *

                *   日期与日历有什么关系 ? 日期是是历中一个具体的日子        

                */

       }

}

猜你喜欢

转载自blog.csdn.net/wyqwilliam/article/details/92801377