WeekFields類的getMinimalDaysInFirstWeek()方法用於返回一個月或一年的第一周的最少天數。例如,ISO-8601需要4天(超過半周)的時間才能出現在計算第一周之前。此方法返回一個月或一年中第一周的最小天數,從1到7。
用法:
public int getMinimalDaysInFirstWeek()
參數:此方法不接受任何內容。
返回值:此方法返回一個月或一年中第一周的最小天數,從1到7。
以下示例程序旨在說明WeekFields.getMinimalDaysInFirstWeek()方法:
程序1:
// Java program to demonstrate
// WeekFields.getMinimalDaysInFirstWeek() method
import java.time.DayOfWeek;
import java.time.temporal.WeekFields;
public class GFG {
public static void main(String[] args)
{
// create WeekFields
WeekFields weekFields
= WeekFields.of(DayOfWeek.SATURDAY, 2);
// apply getMinimalDaysInFirstWeek()
int noOfDays
= weekFields.getMinimalDaysInFirstWeek();
// print results
System.out.println("Minimal number of days"
+ " in the first week:"
+ noOfDays);
}
}
輸出:
Minimal number of days in the first week:2
程序2:
// Java program to demonstrate
// WeekFields.getMinimalDaysInFirstWeek() method
import java.time.temporal.WeekFields;
import java.util.Locale;
public class GFG {
public static void main(String[] args)
{
Locale locale = new Locale("EN", "INDIA");
// create WeekFields
WeekFields weekFields
= WeekFields.of(locale);
// apply getMinimalDaysInFirstWeek()
int noOfDays
= weekFields.getMinimalDaysInFirstWeek();
// print results
System.out.println("Minimal number of days"
+ " in the first week:"
+ noOfDays);
}
}
輸出:
Minimal number of days in the first week:1
參考:https://docs.oracle.com/javase/10/docs/api/java/time/temporal/WeekFields.html#getMinimalDaysInFirstWeek()
相關用法
- Java Calendar getMinimalDaysInFirstWeek()用法及代碼示例
- Java WeekFields of()用法及代碼示例
- Java WeekFields weekBasedYear()用法及代碼示例
- Java WeekFields toString()用法及代碼示例
- Java WeekFields weekOfYear()用法及代碼示例
- Java WeekFields weekOfMonth()用法及代碼示例
- Java WeekFields hashCode()用法及代碼示例
- Java WeekFields weekOfWeekBasedYear()用法及代碼示例
- Java WeekFields getFirstDayOfWeek()用法及代碼示例
- Java WeekFields equals()用法及代碼示例
- Java WeekFields dayOfWeek()用法及代碼示例
- Java Java lang.Long.byteValue()用法及代碼示例
- Java Java.util.Collections.rotate()用法及代碼示例
- Java Java.util.Collections.disjoint()用法及代碼示例
- Java Java lang.Long.numberOfTrailingZeros()用法及代碼示例
注:本文由純淨天空篩選整理自AmanSingh2210大神的英文原創作品 WeekFields getMinimalDaysInFirstWeek() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。