欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

calendar日历

程序员文章站 2022-05-26 22:02:15
...
package com.wyq.StringBuffer;

import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * Calendar是位于java.util包中的
 * 
 * @author administrator
 *
 */
public class TestCal {
	public static void main(String[] args) {
		Calendar cal = new GregorianCalendar();//多态,父类new子类对象
		System.out.println(cal);
		System.out.println("年:" + cal.getFirstDayOfWeek());
		System.out.println(Calendar.YEAR);

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

		System.out.println("月:" + cal.get(Calendar.MONDAY));
		System.out.println("月:" + (cal.get(Calendar.MONDAY) + 3));
		System.out.println("日:" + cal.get(Calendar.DATE));
		System.out.println("date_of_month:" + cal.get(Calendar.DAY_OF_MONTH));
	}

}