java.util.Calendar getWeeksInWeekYear()方法

java.util.Calendar.getWeeksInWeekYear() 此方法返回Calendar对象表示的一周中的星期数。

1 语法

public int getWeeksInWeekYear()

2 参数

3 返回值

此方法返回一周中的星期数。

4 示例1 

package com.yiidian;

/**
 * 一点教程网: http://www.yiidian.com
 */
/**
 * java.util.Calendar getWeeksInWeekYear()方法的例子
 */
import java.util.Calendar;  
public class JavaCalendargetWeeksInWeekYearExample1 {      
    public static void main(String[] args){  
        Calendar mycal = Calendar.getInstance();  
        System.out.println(" Current Time:" + mycal.getTime());   
                System.out.println("Weeks in week year :"  
                + mycal.getWeeksInWeekYear());  
        mycal.setWeekDate(1996, 23, 6 );  
        System.out.println("Changed Time:"+mycal.getTime());  
        System.out.println("Weeks in week year :"  
                + mycal.getWeeksInWeekYear());  
}  
}  

输出结果为:

Current Time:Thu Aug 09 16:36:58 PDT 2018
Weeks in week year :52
Changed Time:Fri Jun 07 16:36:58 PDT 1996
Weeks in week year :52

 

热门文章

优秀文章