113 * depending on the Chronology. 114 * <p>A week is defined by: 115 * <ul> 116 * <li>The first day-of-week. 117 * For example, the ISO-8601 standard considers Monday to be the first day-of-week. 118 * <li>The minimal number of days in the first week. 119 * For example, the ISO-8601 standard counts the first week as needing at least 4 days. 120 * </ul> 121 * Together these two values allow a year or month to be divided into weeks. 122 * 123 * <h3>Week of Month</h3> 124 * One field is used: week-of-month. 125 * The calculation ensures that weeks never overlap a month boundary. 126 * The month is divided into periods where each period starts on the defined first day-of-week. 127 * The earliest period is referred to as week 0 if it has less than the minimal number of days 128 * and week 1 if it has at least the minimal number of days. 129 * 130 * <table class=striped style="text-align: left"> 131 * <caption>Examples of WeekFields</caption> 132 * <thead> 133 * <tr><th>Date</th><td>Day-of-week</td> 134 * <td>First day: Monday<br>Minimal days: 4</td><td>First day: Monday<br>Minimal days: 5</td></tr> 135 * </thead> 136 * <tbody> 137 * <tr><th>2008-12-31</th><td>Wednesday</td> 138 * <td>Week 5 of December 2008</td><td>Week 5 of December 2008</td></tr> 139 * <tr><th>2009-01-01</th><td>Thursday</td> 140 * <td>Week 1 of January 2009</td><td>Week 0 of January 2009</td></tr> 141 * <tr><th>2009-01-04</th><td>Sunday</td> 142 * <td>Week 1 of January 2009</td><td>Week 0 of January 2009</td></tr> 143 * <tr><th>2009-01-05</th><td>Monday</td> 144 * <td>Week 2 of January 2009</td><td>Week 1 of January 2009</td></tr> 145 * </tbody> 146 * </table> 147 * 148 * <h3>Week of Year</h3> 149 * One field is used: week-of-year. 150 * The calculation ensures that weeks never overlap a year boundary. 151 * The year is divided into periods where each period starts on the defined first day-of-week. 152 * The earliest period is referred to as week 0 if it has less than the minimal number of days 153 * and week 1 if it has at least the minimal number of days. 154 * 155 * <h3>Week Based Year</h3> 156 * Two fields are used for week-based-year, one for the 157 * {@link #weekOfWeekBasedYear() week-of-week-based-year} and one for 158 * {@link #weekBasedYear() week-based-year}. In a week-based-year, each week 159 * belongs to only a single year. Week 1 of a year is the first week that 160 * starts on the first day-of-week and has at least the minimum number of days. 161 * The first and last weeks of a year may contain days from the 162 * previous calendar year or next calendar year respectively. 163 * 164 * <table class=striped style="text-align: left;"> 165 * <caption>Examples of WeekFields for week-based-year</caption> 166 * <thead> 167 * <tr><th>Date</th><td>Day-of-week</td> 168 * <td>First day: Monday<br>Minimal days: 4</td><td>First day: Monday<br>Minimal days: 5</td></tr> 169 * </thead> 170 * <tbody> 171 * <tr><th>2008-12-31</th><td>Wednesday</td> 172 * <td>Week 1 of 2009</td><td>Week 53 of 2008</td></tr> 173 * <tr><th>2009-01-01</th><td>Thursday</td> 174 * <td>Week 1 of 2009</td><td>Week 53 of 2008</td></tr> 175 * <tr><th>2009-01-04</th><td>Sunday</td> 176 * <td>Week 1 of 2009</td><td>Week 53 of 2008</td></tr> 177 * <tr><th>2009-01-05</th><td>Monday</td> 178 * <td>Week 2 of 2009</td><td>Week 1 of 2009</td></tr> 179 * </tbody> 180 * </table> 181 * 182 * @implSpec 183 * This class is immutable and thread-safe. 184 * 185 * @since 1.8 186 */ 187 public final class WeekFields implements Serializable { 188 // implementation notes 189 // querying week-of-month or week-of-year should return the week value bound within the month/year 190 // however, setting the week value should be lenient (use plus/minus weeks) 191 // allow week-of-month outer range [0 to 6] 192 // allow week-of-year outer range [0 to 54] 193 // this is because callers shouldn't be expected to know the details of validity 194 195 /** 196 * The cache of rules by firstDayOfWeek plus minimalDays. 197 * Initialized first to be available for definition of ISO, etc. | 113 * depending on the Chronology. 114 * <p>A week is defined by: 115 * <ul> 116 * <li>The first day-of-week. 117 * For example, the ISO-8601 standard considers Monday to be the first day-of-week. 118 * <li>The minimal number of days in the first week. 119 * For example, the ISO-8601 standard counts the first week as needing at least 4 days. 120 * </ul> 121 * Together these two values allow a year or month to be divided into weeks. 122 * 123 * <h3>Week of Month</h3> 124 * One field is used: week-of-month. 125 * The calculation ensures that weeks never overlap a month boundary. 126 * The month is divided into periods where each period starts on the defined first day-of-week. 127 * The earliest period is referred to as week 0 if it has less than the minimal number of days 128 * and week 1 if it has at least the minimal number of days. 129 * 130 * <table class=striped style="text-align: left"> 131 * <caption>Examples of WeekFields</caption> 132 * <thead> 133 * <tr><th scope="col">Date</th><th scope="col">Day-of-week</th> 134 * <th scope="col">First day: Monday<br>Minimal days: 4</th><th scope="col">First day: Monday<br>Minimal days: 5</th></tr> 135 * </thead> 136 * <tbody> 137 * <tr><th scope="row">2008-12-31</th><td>Wednesday</td> 138 * <td>Week 5 of December 2008</td><td>Week 5 of December 2008</td></tr> 139 * <tr><th scope="row">2009-01-01</th><td>Thursday</td> 140 * <td>Week 1 of January 2009</td><td>Week 0 of January 2009</td></tr> 141 * <tr><th scope="row">2009-01-04</th><td>Sunday</td> 142 * <td>Week 1 of January 2009</td><td>Week 0 of January 2009</td></tr> 143 * <tr><th scope="row">2009-01-05</th><td>Monday</td> 144 * <td>Week 2 of January 2009</td><td>Week 1 of January 2009</td></tr> 145 * </tbody> 146 * </table> 147 * 148 * <h3>Week of Year</h3> 149 * One field is used: week-of-year. 150 * The calculation ensures that weeks never overlap a year boundary. 151 * The year is divided into periods where each period starts on the defined first day-of-week. 152 * The earliest period is referred to as week 0 if it has less than the minimal number of days 153 * and week 1 if it has at least the minimal number of days. 154 * 155 * <h3>Week Based Year</h3> 156 * Two fields are used for week-based-year, one for the 157 * {@link #weekOfWeekBasedYear() week-of-week-based-year} and one for 158 * {@link #weekBasedYear() week-based-year}. In a week-based-year, each week 159 * belongs to only a single year. Week 1 of a year is the first week that 160 * starts on the first day-of-week and has at least the minimum number of days. 161 * The first and last weeks of a year may contain days from the 162 * previous calendar year or next calendar year respectively. 163 * 164 * <table class=striped style="text-align: left;"> 165 * <caption>Examples of WeekFields for week-based-year</caption> 166 * <thead> 167 * <tr><th scope="col">Date</th><th scope="col">Day-of-week</th> 168 * <th scope="col">First day: Monday<br>Minimal days: 4</th><th scope="col">First day: Monday<br>Minimal days: 5</th></tr> 169 * </thead> 170 * <tbody> 171 * <tr><th scope="row">2008-12-31</th><td>Wednesday</td> 172 * <td>Week 1 of 2009</td><td>Week 53 of 2008</td></tr> 173 * <tr><th scope="row">2009-01-01</th><td>Thursday</td> 174 * <td>Week 1 of 2009</td><td>Week 53 of 2008</td></tr> 175 * <tr><th scope="row">2009-01-04</th><td>Sunday</td> 176 * <td>Week 1 of 2009</td><td>Week 53 of 2008</td></tr> 177 * <tr><th scope="row">2009-01-05</th><td>Monday</td> 178 * <td>Week 2 of 2009</td><td>Week 1 of 2009</td></tr> 179 * </tbody> 180 * </table> 181 * 182 * @implSpec 183 * This class is immutable and thread-safe. 184 * 185 * @since 1.8 186 */ 187 public final class WeekFields implements Serializable { 188 // implementation notes 189 // querying week-of-month or week-of-year should return the week value bound within the month/year 190 // however, setting the week value should be lenient (use plus/minus weeks) 191 // allow week-of-month outer range [0 to 6] 192 // allow week-of-year outer range [0 to 54] 193 // this is because callers shouldn't be expected to know the details of validity 194 195 /** 196 * The cache of rules by firstDayOfWeek plus minimalDays. 197 * Initialized first to be available for definition of ISO, etc. |