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));
}
}
上一篇: C++之日历