142 if (!cal.checkFieldValue(DAY_OF_YEAR, 293)) { |
142 if (!cal.checkFieldValue(DAY_OF_YEAR, 293)) { |
143 errln(cal.getMessage()); |
143 errln(cal.getMessage()); |
144 } |
144 } |
145 |
145 |
146 logln("Set day of week to SUNDAY and date to 2003/10/31. " |
146 logln("Set day of week to SUNDAY and date to 2003/10/31. " |
147 + "Then, getTime and set week of year to 43."); |
147 + "Then, getTime and set week of year to 43."); |
148 cal.setTime(new Date(2003-1990, OCTOBER, 31)); |
148 |
|
149 @SuppressWarnings("deprecation") |
|
150 Date d = new Date(2003 - 1990, OCTOBER, 31); |
|
151 cal.setTime(d); |
149 cal.set(DAY_OF_WEEK, SUNDAY); |
152 cal.set(DAY_OF_WEEK, SUNDAY); |
150 cal.set(2003, OCTOBER, 31); // 2003/10/31 is Friday. |
153 cal.set(2003, OCTOBER, 31); // 2003/10/31 is Friday. |
151 cal.set(ZONE_OFFSET, 0); |
154 cal.set(ZONE_OFFSET, 0); |
152 cal.set(DST_OFFSET, 0); |
155 cal.set(DST_OFFSET, 0); |
153 |
156 |
164 |
167 |
165 /* |
168 /* |
166 * 4916815: REGRESSION: Problem with java.util.Calendar VM 1.4.2-b28 |
169 * 4916815: REGRESSION: Problem with java.util.Calendar VM 1.4.2-b28 |
167 */ |
170 */ |
168 public void Test4916815() { |
171 public void Test4916815() { |
169 logln("Set date to 2003/9/26 (Fri). Roll to Aug and back to Sep. "+ |
172 logln("Set date to 2003/9/26 (Fri). Roll to Aug and back to Sep. " |
170 "Set dayofweek to Sunday which should be 2003/9/21."); |
173 + "Set dayofweek to Sunday which should be 2003/9/21."); |
171 Koyomi cal = new Koyomi(); |
174 Koyomi cal = new Koyomi(); |
172 cal.clear(); |
175 cal.clear(); |
173 // 2003/9/26 (Fri) |
176 // 2003/9/26 (Fri) |
174 cal.set(2003, SEPTEMBER, 26); |
177 cal.set(2003, SEPTEMBER, 26); |
175 // Go to August then back to September |
178 // Go to August then back to September |
190 public void Test4867075() { |
193 public void Test4867075() { |
191 Koyomi cal = new Koyomi(Locale.US); |
194 Koyomi cal = new Koyomi(Locale.US); |
192 cal.clear(); |
195 cal.clear(); |
193 cal.set(YEAR, 2004); |
196 cal.set(YEAR, 2004); |
194 cal.set(WEEK_OF_YEAR, 1); |
197 cal.set(WEEK_OF_YEAR, 1); |
195 checkDate(cal, SUNDAY, 2003, DECEMBER, 28); |
198 checkDate(cal, SUNDAY, 2003, DECEMBER, 28); |
196 checkDate(cal, MONDAY, 2003, DECEMBER, 29); |
199 checkDate(cal, MONDAY, 2003, DECEMBER, 29); |
197 checkDate(cal, TUESDAY, 2003, DECEMBER, 30); |
200 checkDate(cal, TUESDAY, 2003, DECEMBER, 30); |
198 checkDate(cal, WEDNESDAY, 2003, DECEMBER, 31); |
201 checkDate(cal, WEDNESDAY, 2003, DECEMBER, 31); |
199 checkDate(cal, THURSDAY, 2004, JANUARY, 1); |
202 checkDate(cal, THURSDAY, 2004, JANUARY, 1); |
200 checkDate(cal, FRIDAY, 2004, JANUARY, 2); |
203 checkDate(cal, FRIDAY, 2004, JANUARY, 2); |
201 checkDate(cal, SATURDAY, 2004, JANUARY, 3); |
204 checkDate(cal, SATURDAY, 2004, JANUARY, 3); |
202 } |
205 } |
203 |
206 |
204 private void checkDate(Koyomi cal, int dayOfWeek, |
207 private void checkDate(Koyomi cal, int dayOfWeek, |
205 int expectedYear, int expectedMonth, int expectedDayOfMonth) { |
208 int expectedYear, int expectedMonth, int expectedDayOfMonth) { |
206 cal.set(DAY_OF_WEEK, dayOfWeek); |
209 cal.set(DAY_OF_WEEK, dayOfWeek); |
207 cal.getTime(); |
210 cal.getTime(); |
208 if (!cal.checkInternalDate(expectedYear, expectedMonth, expectedDayOfMonth, dayOfWeek)) { |
211 if (!cal.checkInternalDate(expectedYear, expectedMonth, expectedDayOfMonth, dayOfWeek)) { |
209 errln(cal.getMessage()); |
212 errln(cal.getMessage()); |
210 } |
213 } |