70 import static java.time.temporal.ChronoUnit.YEARS; |
70 import static java.time.temporal.ChronoUnit.YEARS; |
71 |
71 |
72 import java.time.DateTimeException; |
72 import java.time.DateTimeException; |
73 import java.time.Duration; |
73 import java.time.Duration; |
74 import java.time.LocalDate; |
74 import java.time.LocalDate; |
75 import java.time.ZoneId; |
|
76 import java.time.chrono.ChronoLocalDate; |
75 import java.time.chrono.ChronoLocalDate; |
77 import java.time.chrono.Chronology; |
76 import java.time.chrono.Chronology; |
78 import java.time.chrono.IsoChronology; |
77 import java.time.chrono.IsoChronology; |
79 import java.time.format.ResolverStyle; |
78 import java.time.format.ResolverStyle; |
80 import java.util.HashMap; |
|
81 import java.util.Locale; |
79 import java.util.Locale; |
82 import java.util.Map; |
80 import java.util.Map; |
83 import java.util.Objects; |
81 import java.util.Objects; |
84 import java.util.ResourceBundle; |
82 import java.util.ResourceBundle; |
85 |
83 |
100 * April, May and June are in Q2. |
98 * April, May and June are in Q2. |
101 * July, August and September are in Q3. |
99 * July, August and September are in Q3. |
102 * October, November and December are in Q4. |
100 * October, November and December are in Q4. |
103 * <p> |
101 * <p> |
104 * The complete date is expressed using three fields: |
102 * The complete date is expressed using three fields: |
105 * <p><ul> |
103 * <ul> |
106 * <li>{@link #DAY_OF_QUARTER DAY_OF_QUARTER} - the day within the quarter, from 1 to 90, 91 or 92 |
104 * <li>{@link #DAY_OF_QUARTER DAY_OF_QUARTER} - the day within the quarter, from 1 to 90, 91 or 92 |
107 * <li>{@link #QUARTER_OF_YEAR QUARTER_OF_YEAR} - the week within the week-based-year |
105 * <li>{@link #QUARTER_OF_YEAR QUARTER_OF_YEAR} - the week within the week-based-year |
108 * <li>{@link ChronoField#YEAR YEAR} - the standard ISO year |
106 * <li>{@link ChronoField#YEAR YEAR} - the standard ISO year |
109 * </ul><p> |
107 * </ul> |
110 * |
108 * |
111 * <h3>Week based years</h3> |
109 * <h3>Week based years</h3> |
112 * The ISO-8601 standard was originally intended as a data interchange format, |
110 * The ISO-8601 standard was originally intended as a data interchange format, |
113 * defining a string format for dates and times. However, it also defines an |
111 * defining a string format for dates and times. However, it also defines an |
114 * alternate way of expressing the date, based on the concept of week-based-year. |
112 * alternate way of expressing the date, based on the concept of week-based-year. |
115 * <p> |
113 * <p> |
116 * The date is expressed using three fields: |
114 * The date is expressed using three fields: |
117 * <p><ul> |
115 * <ul> |
118 * <li>{@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} - the standard field defining the |
116 * <li>{@link ChronoField#DAY_OF_WEEK DAY_OF_WEEK} - the standard field defining the |
119 * day-of-week from Monday (1) to Sunday (7) |
117 * day-of-week from Monday (1) to Sunday (7) |
120 * <li>{@link #WEEK_OF_WEEK_BASED_YEAR} - the week within the week-based-year |
118 * <li>{@link #WEEK_OF_WEEK_BASED_YEAR} - the week within the week-based-year |
121 * <li>{@link #WEEK_BASED_YEAR WEEK_BASED_YEAR} - the week-based-year |
119 * <li>{@link #WEEK_BASED_YEAR WEEK_BASED_YEAR} - the week-based-year |
122 * </ul><p> |
120 * </ul> |
123 * The week-based-year itself is defined relative to the standard ISO proleptic year. |
121 * The week-based-year itself is defined relative to the standard ISO proleptic year. |
124 * It differs from the standard year in that it always starts on a Monday. |
122 * It differs from the standard year in that it always starts on a Monday. |
125 * <p> |
123 * <p> |
126 * The first week of a week-based-year is the first Monday-based week of the standard |
124 * The first week of a week-based-year is the first Monday-based week of the standard |
127 * ISO year that has at least 4 days in the new year. |
125 * ISO year that has at least 4 days in the new year. |
128 * <p><ul> |
126 * <ul> |
129 * <li>If January 1st is Monday then week 1 starts on January 1st |
127 * <li>If January 1st is Monday then week 1 starts on January 1st |
130 * <li>If January 1st is Tuesday then week 1 starts on December 31st of the previous standard year |
128 * <li>If January 1st is Tuesday then week 1 starts on December 31st of the previous standard year |
131 * <li>If January 1st is Wednesday then week 1 starts on December 30th of the previous standard year |
129 * <li>If January 1st is Wednesday then week 1 starts on December 30th of the previous standard year |
132 * <li>If January 1st is Thursday then week 1 starts on December 29th of the previous standard year |
130 * <li>If January 1st is Thursday then week 1 starts on December 29th of the previous standard year |
133 * <li>If January 1st is Friday then week 1 starts on January 4th |
131 * <li>If January 1st is Friday then week 1 starts on January 4th |
134 * <li>If January 1st is Saturday then week 1 starts on January 3rd |
132 * <li>If January 1st is Saturday then week 1 starts on January 3rd |
135 * <li>If January 1st is Sunday then week 1 starts on January 2nd |
133 * <li>If January 1st is Sunday then week 1 starts on January 2nd |
136 * </ul><p> |
134 * </ul> |
137 * There are 52 weeks in most week-based years, however on occasion there are 53 weeks. |
135 * There are 52 weeks in most week-based years, however on occasion there are 53 weeks. |
138 * <p> |
136 * <p> |
139 * For example: |
137 * For example: |
140 * <p> |
138 * |
141 * <table cellpadding="0" cellspacing="3" border="0" style="text-align: left; width: 50%;"> |
139 * <table cellpadding="0" cellspacing="3" border="0" style="text-align: left; width: 50%;"> |
142 * <caption>Examples of Week based Years</caption> |
140 * <caption>Examples of Week based Years</caption> |
143 * <tr><th>Date</th><th>Day-of-week</th><th>Field values</th></tr> |
141 * <tr><th>Date</th><th>Day-of-week</th><th>Field values</th></tr> |
144 * <tr><th>2008-12-28</th><td>Sunday</td><td>Week 52 of week-based-year 2008</td></tr> |
142 * <tr><th>2008-12-28</th><td>Sunday</td><td>Week 52 of week-based-year 2008</td></tr> |
145 * <tr><th>2008-12-29</th><td>Monday</td><td>Week 1 of week-based-year 2009</td></tr> |
143 * <tr><th>2008-12-29</th><td>Monday</td><td>Week 1 of week-based-year 2009</td></tr> |