java.util.Calendar setWeekDate()方法

java.util.Calendar.setWeekDate() 方法使用指定的整数值作为参数设置当前日期。这些值是weekYear,weekOfYear和dayOfWeek。

1 语法

public void setWeekDate(int weekYear, int weekOfYear, int dayOfWeek)  

2 参数

weekYear:周年

weekOfYear:基于weekYear的星期数

dayOfWeek:星期几的值

3 返回值

4 示例1 

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * java.util.Calendar setWeekDate()方法的例子
 */
import java.util.Calendar;  

public class JavaCalendarsetWeekDateExample1 {  
    public static void main(String[] args){  
                             // creating new calendar object mycal  
        Calendar mycal = Calendar.getInstance();  
              //by using getTime method geting the Todays Time   
        System.out.println("  Time Today:" + mycal.getTime());  
                // setting the weekyear , weekofyear and dayofweek using setWeekDate  
        mycal.setWeekDate(1996, 23, 6);  
        System.out.println("Now Time Today:"+mycal.getTime());    
    }  
}  

输出结果为:

Time Today:Sat Aug 18 10:57:54 PDT 2018
Now Time Today:Fri Jun 07 10:57:54 PDT 1996

 

热门文章

优秀文章