java.util.Calendar getWeekYear()方法

java.util.Calendar.getWeekYear() 方法是一个公共方法。此方法获取日历对象的星期年,并以整数返回日历的星期年。

1 语法

public int getWeekYear()  

2 参数

3 返回值

返回当前日历对象的整数周年。

4 示例1 

package com.yiidian;

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

输出结果为:

Current Time:Fri Aug 10 10:52:54 PDT 2018
 week year :2018
Changed Time:Fri Jun 07 10:52:54 PDT 1996
Weeks in week year :1996

 

热门文章

优秀文章