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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。