java.util.Calendar 类的 getWeekYear() 方法是一个公共方法。此方法获取日历对象的周年并以整数形式返回日历的周年。
用法
public int getWeekYear()
参数
没有传递参数。
返回
返回当前日历对象的整数周年。
抛出
UnsupportedOperationException
例子1
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
例子2
import java.util.Calendar;
public class JavaCalendargetWeekYearExample2 {
public static void main(String args[])
{
Calendar mycal = Calendar.getInstance();
mycal.setFirstDayOfWeek(Calendar.SUNDAY);
mycal.setMinimalDaysInFirstWeek(7);
mycal.setTimeInMillis(100);
int wk = mycal.get(Calendar.WEEK_OF_YEAR);
System.out.println("Week:" +wk);
int wY = mycal.getWeekYear();
System.out.println("Weekayear :" +wY);
int y = mycal.get(Calendar.YEAR);
System.out.println("Year :" +y);
}
}
输出:
Week:52 Weekayear :1969 Year :1969
相关用法
- Java Calendar getWeeksInWeekYear()用法及代码示例
- Java Calendar get()用法及代码示例
- Java Calendar getDisplayName()用法及代码示例
- Java Calendar getGreatestMinimum()用法及代码示例
- Java Calendar getCalendarType()用法及代码示例
- Java Calendar getAvailableLocales()用法及代码示例
- Java Calendar getInstance()用法及代码示例
- Java Calendar getLeastMaximum()用法及代码示例
- Java Calendar getTime()用法及代码示例
- Java Calendar getMinimum()用法及代码示例
- Java Calendar getActualMaximum()用法及代码示例
- Java Calendar getAvailableCalendarTypes()用法及代码示例
- Java Calendar getTimeInMillis()用法及代码示例
- Java Calendar getMaximum()用法及代码示例
- Java Calendar getFirstDayOfWeek()用法及代码示例
- Java Calendar getActualMinimum()用法及代码示例
- Java Calendar getDisplayNames()用法及代码示例
- Java Calendar getTimeZone()用法及代码示例
- Java Calendar getMinimalDaysInFirstWeek()用法及代码示例
- Java Calendar add()用法及代码示例
注:本文由纯净天空筛选整理自 Java Calendar getWeekYear() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。