A standard week is seven days long, but cultures have different definitions for some other aspects of a week. This class represents the definition of the week, for the purpose of providing {@link TemporalField} instances.
WeekFields provides three fields, {@link #dayOfWeek()}, {@link #weekOfMonth()}, and {@link #weekOfYear()}that provide access to the values from any {@link Temporal temporal object}.
The computations for day-of-week, week-of-month, and week-of-year are based on the {@link ChronoField#YEAR proleptic-year}, {@link ChronoField#MONTH_OF_YEAR month-of-year}, {@link ChronoField#DAY_OF_MONTH day-of-month}, and {@link ChronoField#DAY_OF_WEEK ISO day-of-week} which are based on the{@link ChronoField#EPOCH_DAY epoch-day} and the chronology.The values may not be aligned with the {@link ChronoField#YEAR_OF_ERA year-of-Era}depending on the Chronology.
A week is defined by:
Together these two values allow a year or month to be divided into weeks.
Date | Day-of-week | First day: Monday Minimal days: 4 | First day: Monday Minimal days: 5 |
---|---|---|---|
2008-12-31 | Wednesday | Week 5 of December 2008 | Week 5 of December 2008 |
2009-01-01 | Thursday | Week 1 of January 2009 | Week 0 of January 2009 |
2009-01-04 | Sunday | Week 1 of January 2009 | Week 0 of January 2009 |
2009-01-05 | Monday | Week 2 of January 2009 | Week 1 of January 2009 |
This class is immutable and thread-safe.
|
|
|
|