Calendar 类的 setMinimalDaysInFirstWeek() 方法用于设置第一周所需的最少天数。将在第一周设置为最少天数的值作为参数传递。
用法
public void setMinimalDaysInFirstWeek(int value)
参数
值 - 此值设置为第一周所需的最少天数。
返回
不返回值。
抛出
不抛出异常。
例子1
import java.util.Calendar;
public class JavaCalendarsetMinimalDaysInFirstWeekExample1 {
public static void main(String[] args) {
// create a calendar
Calendar calobj = Calendar.getInstance();
calobj.setMinimalDaysInFirstWeek(5);
System.out.println(" Today is:" + calobj.getTime());
int day = calobj.getMinimalDaysInFirstWeek();
// print the result
System.out.println("Minimal days in first week required:" + day);
}
}
输出:
Today is:Wed Aug 15 18:29:43 PDT 2018 Minimal days in first week required:5
例子2
import java.util.Calendar;
import java.util.GregorianCalendar;
public class JavaCalendarsetMinimalDaysInFirstWeekExample2 {
public static void main(String[] args) {
// create 2 calendar
Calendar calobj = Calendar.getInstance();
GregorianCalendar calobj2 =(GregorianCalendar) GregorianCalendar.getInstance();
System.out.println(" Today (Calendarobject):" + calobj.getTime());
System.out.println(" Today (GregorianCalendarobject):" + calobj.getTime());
calobj.setMinimalDaysInFirstWeek(9);
calobj2.setMinimalDaysInFirstWeek(9);
if(calobj.getMinimalDaysInFirstWeek()== calobj2.getMinimalDaysInFirstWeek())
System.out.println("both the calendar object require same Minimal days in first week " +calobj.getMinimalDaysInFirstWeek());
}
}
输出:
Today (Calendarobject):Wed Aug 15 18:32:25 PDT 2018 Today (GregorianCalendarobject):Wed Aug 15 18:32:25 PDT 2018 both the calendar object require same Minimal days in first week 9
相关用法
- Java Calendar setMinimalDaysInFirstWeek()用法及代码示例
- Java Calendar setTimeZone()用法及代码示例
- Java Calendar setFirstDayOfWeek()用法及代码示例
- Java Calendar setTimeInMillis()用法及代码示例
- Java Calendar setWeekDate()用法及代码示例
- Java Calendar setTimZone()用法及代码示例
- Java Calendar set()用法及代码示例
- Java Calendar setTime()用法及代码示例
- Java Calendar setLenient()用法及代码示例
- Java Calendar get()用法及代码示例
- Java Calendar add()用法及代码示例
- Java Calendar getWeekYear()用法及代码示例
- Java Calendar computeFields()用法及代码示例
- Java Calendar after()用法及代码示例
- Java Calendar complete()用法及代码示例
- Java Calendar compareTo()用法及代码示例
- Java Calendar getDisplayName()用法及代码示例
- Java Calendar getGreatestMinimum()用法及代码示例
- Java Calendar clear()用法及代码示例
- Java Calendar roll(int calndr_field, int amt)用法及代码示例
注:本文由纯净天空筛选整理自 Java Calendar setMinimalDaysInFirstWeek() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。