java.util.Calendar 类的 getWeeksInWeekYear() 方法以整数形式返回一周年中的总周数。
用法
public int getWeeksInWeekYear()
参数
没有传递参数。
返回
返回周年中的整数周数
抛出
UnsupportedOperationException:如果日历中未定义任何周数。
例子1
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
例子2
import java.util.Calendar;
public class JavaCalendargetWeeksInWeekYearExample2 {
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);
int w = mycal.getWeeksInWeekYear();
System.out.println("Week:" +w);
}
}
输出:
Week:52 Weekayear :1969 Year :1969 Week:52
相关用法
- Java Calendar getWeekYear()用法及代码示例
- 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 getWeeksInWeekYear() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。