WeekFields类的getFirstDayOfWeek()方法用于将第一个day-of-week作为DayOfWeek枚举返回,例如,美国使用星期日,而法国使用星期一。
用法:
public DayOfWeek getFirstDayOfWeek()
参数:此方法不接受任何内容。
返回值:此方法返回第一个day-of-week,不为null。
以下示例程序旨在说明WeekFields.getFirstDayOfWeek()方法:
程序1:
// Java program to demonstrate
// WeekFields.getFirstDayOfWeek() 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.MONDAY, 1);
// apply getFirstDayOfWeek()
DayOfWeek firstDay
= weekFields.getFirstDayOfWeek();
// print results
System.out.println("First Day:"
+ firstDay);
}
}
输出:
First Day:MONDAY
程序2:
// Java program to demonstrate
// WeekFields.getFirstDayOfWeek() method
import java.time.DayOfWeek;
import java.time.temporal.WeekFields;
import java.util.Locale;
public class GFG {
public static void main(String[] args)
{
Locale locale = new Locale("EN", "US");
// create WeekFields
WeekFields weekFields
= WeekFields.of(locale);
// apply getFirstDayOfWeek()
DayOfWeek firstDay
= weekFields.getFirstDayOfWeek();
// print results
System.out.println("First Day:"
+ firstDay);
}
}
输出:
First Day:SUNDAY
参考:https://docs.oracle.com/javase/10/docs/api/java/time/temporal/WeekFields.html#getFirstDayOfWeek()
相关用法
- Java Calendar getFirstDayOfWeek()用法及代码示例
- Java WeekFields of()用法及代码示例
- Java WeekFields weekBasedYear()用法及代码示例
- Java WeekFields dayOfWeek()用法及代码示例
- Java WeekFields weekOfYear()用法及代码示例
- Java WeekFields weekOfMonth()用法及代码示例
- Java WeekFields toString()用法及代码示例
- Java WeekFields getMinimalDaysInFirstWeek()用法及代码示例
- Java WeekFields weekOfWeekBasedYear()用法及代码示例
- Java WeekFields hashCode()用法及代码示例
- Java WeekFields equals()用法及代码示例
- Java Java lang.Long.highestOneBit()用法及代码示例
- Java Java.util.Collections.disjoint()用法及代码示例
- Java Java lang.Long.numberOfLeadingZeros()用法及代码示例
注:本文由纯净天空筛选整理自AmanSingh2210大神的英文原创作品 WeekFields getFirstDayOfWeek() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。