日历对象


package test01;

//Alt+Enter,可以导入

import java.text.SimpleDateFormat;
import java.util.Calendar;
import static java.util.Calendar.*;

//2015
public  class  Test{
    public static void main(String[] args) {
        Calendar rightNow = Calendar.getInstance();
        System.out.println("+++");
        System.out.println("+++");
        System.out.println("+++");
        System.out.println("+++");
     
        int year = rightNow.get(Calendar.YEAR);
        System.out.println(year);
        int month = rightNow.get(Calendar.MONTH);
        System.out.println(month);
        //一个月中的第几天
        int day = rightNow.get(DAY_OF_MONTH);
        System.out.println(day);

        //让日历中的第几天,往后走几天
        rightNow.add(Calendar.DAY_OF_YEAR,239);
        //让小时往后走
        rightNow.add(Calendar.HOUR,68);
        long time1 = rightNow.getTimeInMillis();
        SimpleDateFormat std = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss EEE a");
        System.out.println(std.format(time1));
    }
}





日历对象(图1)

您可能还会对下面的文章感兴趣: