1 /* 2 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * This file is available under and governed by the GNU General Public 26 * License version 2 only, as published by the Free Software Foundation. 27 * However, the following notice accompanied the original version of this 28 * file: 29 * 30 * Copyright (c) 2012, Stephen Colebourne & Michael Nascimento Santos 31 * 32 * All rights reserved. 33 * 34 * Redistribution and use in source and binary forms, with or without 35 * modification, are permitted provided that the following conditions are met: 36 * 37 * * Redistributions of source code must retain the above copyright notice, 38 * this list of conditions and the following disclaimer. 39 * 40 * * Redistributions in binary form must reproduce the above copyright notice, 41 * this list of conditions and the following disclaimer in the documentation 42 * and/or other materials provided with the distribution. 43 * 44 * * Neither the name of JSR-310 nor the names of its contributors 45 * may be used to endorse or promote products derived from this software 46 * without specific prior written permission. 47 * 48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 49 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 50 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 51 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 52 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 53 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 54 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 55 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 56 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 58 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 */ 60 package tck.java.time.chrono; 61 62 import static org.testng.Assert.assertEquals; 63 import static org.testng.Assert.assertNotNull; 64 import static org.testng.Assert.assertSame; 65 import static org.testng.Assert.assertTrue; 66 67 import dalvik.annotation.compat.VersionCodes; 68 69 import libcore.test.annotation.NonMts; 70 import libcore.test.reasons.NonMtsReasons; 71 72 import java.io.ByteArrayInputStream; 73 import java.io.ByteArrayOutputStream; 74 import java.io.ObjectInputStream; 75 import java.io.ObjectOutputStream; 76 import java.time.Clock; 77 import java.time.DateTimeException; 78 import java.time.LocalDate; 79 import java.time.LocalTime; 80 import java.time.OffsetDateTime; 81 import java.time.ZoneId; 82 import java.time.ZoneOffset; 83 import java.time.chrono.ChronoLocalDate; 84 import java.time.chrono.Chronology; 85 import java.time.chrono.Era; 86 import java.time.chrono.HijrahChronology; 87 import java.time.chrono.HijrahEra; 88 import java.time.chrono.IsoChronology; 89 import java.time.chrono.IsoEra; 90 import java.time.chrono.JapaneseChronology; 91 import java.time.chrono.JapaneseEra; 92 import java.time.chrono.MinguoChronology; 93 import java.time.chrono.MinguoEra; 94 import java.time.chrono.ThaiBuddhistChronology; 95 import java.time.chrono.ThaiBuddhistEra; 96 import java.time.format.TextStyle; 97 import java.time.temporal.ChronoField; 98 import java.util.Locale; 99 import java.util.Set; 100 101 import org.testng.annotations.DataProvider; 102 import org.testng.annotations.Test; 103 104 /** 105 * Test Chronology class. 106 */ 107 @Test 108 public class TCKChronology { 109 110 private static final ZoneOffset OFFSET_P0100 = ZoneOffset.ofHours(1); 111 private static final ZoneOffset OFFSET_M0100 = ZoneOffset.ofHours(-1); 112 113 private static final int YDIFF_MEIJI = 1867; 114 private static final int YDIFF_SHOWA = 1925; 115 private static final int YDIFF_HEISEI = 1988; 116 private static final int YDIFF_MINGUO = 1911; 117 private static final int YDIFF_THAIBUDDHIST = 543; 118 //----------------------------------------------------------------------- 119 // regular data factory for ID and calendarType of available calendars 120 //----------------------------------------------------------------------- 121 @DataProvider(name = "calendarNameAndType") data_of_calendars()122 Object[][] data_of_calendars() { 123 return new Object[][] { 124 {"Hijrah-umalqura", "islamic-umalqura"}, 125 {"ISO", "iso8601"}, 126 {"Japanese", "japanese"}, 127 {"Minguo", "roc"}, 128 {"ThaiBuddhist", "buddhist"}, 129 }; 130 } 131 132 @Test(dataProvider = "calendarNameAndType") test_getters(String chronoId, String calendarSystemType)133 public void test_getters(String chronoId, String calendarSystemType) { 134 Chronology chrono = Chronology.of(chronoId); 135 assertNotNull(chrono, "Required calendar not found by ID: " + chronoId); 136 assertEquals(chrono.getId(), chronoId); 137 assertEquals(chrono.getCalendarType(), calendarSystemType); 138 } 139 140 @Test(dataProvider = "calendarNameAndType") test_required_calendars(String chronoId, String calendarSystemType)141 public void test_required_calendars(String chronoId, String calendarSystemType) { 142 Chronology chrono = Chronology.of(chronoId); 143 assertNotNull(chrono, "Required calendar not found by ID: " + chronoId); 144 chrono = Chronology.of(calendarSystemType); 145 assertNotNull(chrono, "Required calendar not found by type: " + chronoId); 146 Set<Chronology> cals = Chronology.getAvailableChronologies(); 147 assertTrue(cals.contains(chrono), "Required calendar not found in set of available calendars"); 148 } 149 150 @Test test_calendar_list()151 public void test_calendar_list() { 152 Set<Chronology> chronos = Chronology.getAvailableChronologies(); 153 assertNotNull(chronos, "Required list of calendars must be non-null"); 154 for (Chronology chrono : chronos) { 155 Chronology lookup = Chronology.of(chrono.getId()); 156 assertNotNull(lookup, "Required calendar not found: " + chrono); 157 } 158 assertEquals(chronos.size() >= data_of_calendars().length, true, "Chronology.getAvailableChronologies().size = " + chronos.size() 159 + ", expected >= " + data_of_calendars().length); 160 } 161 162 //----------------------------------------------------------------------- 163 // getDisplayName() 164 //----------------------------------------------------------------------- 165 @DataProvider(name = "calendarDisplayName") data_of_calendarDisplayNames()166 Object[][] data_of_calendarDisplayNames() { 167 // Android-changed: Change expected values to CLDR values here. This test seems to be based 168 // on an old CLDR version (21) with some "invented" values (specifically Hijrah and ISO). 169 return new Object[][] { 170 {"Hijrah", "Hijri Calendar (Umm al-Qura)"}, 171 {"ISO", "ISO-8601 Calendar"}, 172 {"Japanese", "Japanese Calendar"}, 173 {"Minguo", "Minguo Calendar"}, 174 {"ThaiBuddhist", "Buddhist Calendar"}, 175 }; 176 } 177 178 @NonMts(reason = NonMtsReasons.ICU_VERSION_DEPENDENCY, 179 disabledUntilSdk = VersionCodes.VANILLA_ICE_CREAM) 180 @Test(dataProvider = "calendarDisplayName") test_getDisplayName(String chronoId, String calendarDisplayName)181 public void test_getDisplayName(String chronoId, String calendarDisplayName) { 182 Chronology chrono = Chronology.of(chronoId); 183 assertEquals(chrono.getDisplayName(TextStyle.FULL, Locale.ENGLISH), calendarDisplayName); 184 } 185 186 /** 187 * Compute the number of days from the Epoch and compute the date from the number of days. 188 */ 189 @Test(dataProvider = "calendarNameAndType") test_epoch(String name, String alias)190 public void test_epoch(String name, String alias) { 191 Chronology chrono = Chronology.of(name); // a chronology. In practice this is rarely hardcoded 192 ChronoLocalDate date1 = chrono.dateNow(); 193 long epoch1 = date1.getLong(ChronoField.EPOCH_DAY); 194 ChronoLocalDate date2 = date1.with(ChronoField.EPOCH_DAY, epoch1); 195 assertEquals(date1, date2, "Date from epoch day is not same date: " + date1 + " != " + date2); 196 long epoch2 = date1.getLong(ChronoField.EPOCH_DAY); 197 assertEquals(epoch1, epoch2, "Epoch day not the same: " + epoch1 + " != " + epoch2); 198 } 199 200 @Test(dataProvider = "calendarNameAndType") test_dateEpochDay(String name, String alias)201 public void test_dateEpochDay(String name, String alias) { 202 Chronology chrono = Chronology.of(name); 203 ChronoLocalDate date = chrono.dateNow(); 204 long epochDay = date.getLong(ChronoField.EPOCH_DAY); 205 ChronoLocalDate test = chrono.dateEpochDay(epochDay); 206 assertEquals(test, date); 207 } 208 209 //----------------------------------------------------------------------- 210 // locale based lookup 211 //----------------------------------------------------------------------- 212 @DataProvider(name = "calendarsystemtype") data_CalendarType()213 Object[][] data_CalendarType() { 214 return new Object[][] { 215 {HijrahChronology.INSTANCE, "islamic-umalqura"}, 216 {IsoChronology.INSTANCE, "iso8601"}, 217 {JapaneseChronology.INSTANCE, "japanese"}, 218 {MinguoChronology.INSTANCE, "roc"}, 219 {ThaiBuddhistChronology.INSTANCE, "buddhist"}, 220 }; 221 } 222 223 @Test(dataProvider = "calendarsystemtype") test_getCalendarType(Chronology chrono, String calendarType)224 public void test_getCalendarType(Chronology chrono, String calendarType) { 225 String type = calendarType; 226 assertEquals(chrono.getCalendarType(), type); 227 } 228 229 @Test(dataProvider = "calendarsystemtype") test_lookupLocale(Chronology chrono, String calendarType)230 public void test_lookupLocale(Chronology chrono, String calendarType) { 231 Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA"); 232 builder.setUnicodeLocaleKeyword("ca", calendarType); 233 Locale locale = builder.build(); 234 assertEquals(Chronology.ofLocale(locale), chrono); 235 } 236 237 //----------------------------------------------------------------------- 238 // dateNow() 239 //----------------------------------------------------------------------- 240 @Test test_MinguoChronology_dateNow()241 public void test_MinguoChronology_dateNow() { 242 ZoneId zoneId_paris = ZoneId.of("Europe/Paris"); 243 Clock clock = Clock.system(zoneId_paris); 244 245 Chronology chrono = Chronology.of("Minguo"); 246 assertEquals(chrono.dateNow(), MinguoChronology.INSTANCE.dateNow()); 247 assertEquals(chrono.dateNow(zoneId_paris), MinguoChronology.INSTANCE.dateNow(zoneId_paris)); 248 assertEquals(chrono.dateNow(clock), MinguoChronology.INSTANCE.dateNow(clock)); 249 } 250 251 @Test test_IsoChronology_dateNow()252 public void test_IsoChronology_dateNow() { 253 ZoneId zoneId_paris = ZoneId.of("Europe/Paris"); 254 Clock clock = Clock.system(zoneId_paris); 255 256 Chronology chrono = Chronology.of("ISO"); 257 assertEquals(chrono.dateNow(), IsoChronology.INSTANCE.dateNow()); 258 assertEquals(chrono.dateNow(zoneId_paris), IsoChronology.INSTANCE.dateNow(zoneId_paris)); 259 assertEquals(chrono.dateNow(clock), IsoChronology.INSTANCE.dateNow(clock)); 260 } 261 262 @Test test_JapaneseChronology_dateNow()263 public void test_JapaneseChronology_dateNow() { 264 ZoneId zoneId_paris = ZoneId.of("Europe/Paris"); 265 Clock clock = Clock.system(zoneId_paris); 266 267 Chronology chrono = Chronology.of("Japanese"); 268 assertEquals(chrono.dateNow(), JapaneseChronology.INSTANCE.dateNow()); 269 assertEquals(chrono.dateNow(zoneId_paris), JapaneseChronology.INSTANCE.dateNow(zoneId_paris)); 270 assertEquals(chrono.dateNow(clock), JapaneseChronology.INSTANCE.dateNow(clock)); 271 } 272 273 @Test test_ThaiBuddhistChronology_dateNow()274 public void test_ThaiBuddhistChronology_dateNow() { 275 ZoneId zoneId_paris = ZoneId.of("Europe/Paris"); 276 Clock clock = Clock.system(zoneId_paris); 277 278 Chronology chrono = Chronology.of("ThaiBuddhist"); 279 assertEquals(chrono.dateNow(), ThaiBuddhistChronology.INSTANCE.dateNow()); 280 assertEquals(chrono.dateNow(zoneId_paris), ThaiBuddhistChronology.INSTANCE.dateNow(zoneId_paris)); 281 assertEquals(chrono.dateNow(clock), ThaiBuddhistChronology.INSTANCE.dateNow(clock)); 282 } 283 284 //----------------------------------------------------------------------- 285 // dateYearDay() and date() 286 //----------------------------------------------------------------------- 287 @Test test_HijrahChronology_dateYearDay()288 public void test_HijrahChronology_dateYearDay() { 289 Chronology chrono = Chronology.of("Hijrah"); 290 ChronoLocalDate date1 = chrono.dateYearDay(HijrahEra.AH, 1434, 178); 291 ChronoLocalDate date2 = chrono.date(HijrahEra.AH, 1434, 7, 1); 292 assertEquals(date1, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178)); 293 assertEquals(date2, HijrahChronology.INSTANCE.dateYearDay(HijrahEra.AH, 1434, 178)); 294 } 295 296 @Test test_MinguoChronology_dateYearDay()297 public void test_MinguoChronology_dateYearDay() { 298 Chronology chrono = Chronology.of("Minguo"); 299 ChronoLocalDate date1 = chrono.dateYearDay(MinguoEra.ROC, 5, 60); 300 ChronoLocalDate date2 = chrono.date(MinguoEra.ROC, 5, 2, 29); 301 assertEquals(date1, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60)); 302 assertEquals(date2, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60)); 303 } 304 305 @Test test_IsoChronology_dateYearDay()306 public void test_IsoChronology_dateYearDay() { 307 Chronology chrono = Chronology.of("ISO"); 308 ChronoLocalDate date1 = chrono.dateYearDay(IsoEra.CE, 5, 60); 309 ChronoLocalDate date2 = chrono.date(IsoEra.CE, 5, 3, 1); 310 assertEquals(date1, IsoChronology.INSTANCE.dateYearDay(IsoEra.CE, 5, 60)); 311 assertEquals(date2, IsoChronology.INSTANCE.dateYearDay(IsoEra.CE, 5, 60)); 312 } 313 314 @Test test_JapaneseChronology_dateYearDay()315 public void test_JapaneseChronology_dateYearDay() { 316 Chronology chrono = Chronology.of("Japanese"); 317 ChronoLocalDate date1 = chrono.dateYearDay(JapaneseEra.HEISEI, 8, 60); 318 ChronoLocalDate date2 = chrono.date(JapaneseEra.HEISEI, 8, 2, 29); 319 assertEquals(date1, JapaneseChronology.INSTANCE.dateYearDay(JapaneseEra.HEISEI, 8, 60)); 320 assertEquals(date2, JapaneseChronology.INSTANCE.dateYearDay(JapaneseEra.HEISEI, 8, 60)); 321 } 322 323 @Test test_ThaiBuddhistChronology_dateYearDay()324 public void test_ThaiBuddhistChronology_dateYearDay() { 325 Chronology chrono = Chronology.of("ThaiBuddhist"); 326 ChronoLocalDate date1 = chrono.dateYearDay(ThaiBuddhistEra.BE, 2459, 60); 327 ChronoLocalDate date2 = chrono.date(ThaiBuddhistEra.BE, 2459, 2, 29); 328 assertEquals(date1, ThaiBuddhistChronology.INSTANCE.dateYearDay(ThaiBuddhistEra.BE, 2459, 60)); 329 assertEquals(date2, ThaiBuddhistChronology.INSTANCE.dateYearDay(ThaiBuddhistEra.BE, 2459, 60)); 330 } 331 332 /** 333 * Test lookup by calendarType of each chronology. 334 * Verify that the calendar can be found by {@link java.time.chrono.Chronology#ofLocale}. 335 */ 336 @Test test_ofLocaleByType()337 public void test_ofLocaleByType() { 338 // Test that all available chronologies can be successfully found using ofLocale 339 Set<Chronology> chronos = Chronology.getAvailableChronologies(); 340 for (Chronology chrono : chronos) { 341 Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA"); 342 builder.setUnicodeLocaleKeyword("ca", chrono.getCalendarType()); 343 Locale locale = builder.build(); 344 assertEquals(Chronology.ofLocale(locale), chrono, "Lookup by type"); 345 } 346 } 347 348 @Test(expectedExceptions = DateTimeException.class) test_lookupLocale()349 public void test_lookupLocale() { 350 Locale.Builder builder = new Locale.Builder().setLanguage("en").setRegion("CA"); 351 builder.setUnicodeLocaleKeyword("ca", "xxx"); 352 353 Locale locale = builder.build(); 354 Chronology.ofLocale(locale); 355 } 356 357 @Test(expectedExceptions = DateTimeException.class) test_noChrono()358 public void test_noChrono() { 359 Chronology chrono = Chronology.of("FooFoo"); 360 } 361 362 @DataProvider(name = "epochSecond_dataProvider") data_epochSecond()363 Object[][] data_epochSecond() { 364 return new Object[][] { 365 {JapaneseChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100}, 366 {JapaneseChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100}, 367 {JapaneseChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100}, 368 {HijrahChronology.INSTANCE, 1434, 9, 7, 1, 2, 2, OFFSET_P0100}, 369 {MinguoChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100}, 370 {MinguoChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100}, 371 {MinguoChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100}, 372 {ThaiBuddhistChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100}, 373 {ThaiBuddhistChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100}, 374 {ThaiBuddhistChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100}, 375 {IsoChronology.INSTANCE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100}, 376 {IsoChronology.INSTANCE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100}, 377 {IsoChronology.INSTANCE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100}, 378 379 }; 380 } 381 382 @Test(dataProvider = "epochSecond_dataProvider") test_epochSecond(Chronology chrono, int y, int m, int d, int h, int min, int s, ZoneOffset offset)383 public void test_epochSecond(Chronology chrono, int y, int m, int d, int h, int min, int s, ZoneOffset offset) { 384 ChronoLocalDate chronoLd = chrono.date(y, m, d); 385 assertEquals(chrono.epochSecond(y, m, d, h, min, s, offset), 386 OffsetDateTime.of(LocalDate.from(chronoLd), LocalTime.of(h, min, s), offset) 387 .toEpochSecond()); 388 } 389 390 @DataProvider(name = "era_epochSecond_dataProvider") data_era_epochSecond()391 Object[][] data_era_epochSecond() { 392 return new Object[][] { 393 {JapaneseChronology.INSTANCE, JapaneseEra.MEIJI, 1873 - YDIFF_MEIJI, 9, 7, 1, 2, 2, OFFSET_P0100}, 394 {JapaneseChronology.INSTANCE, JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 2, 28, 1, 2, 2, OFFSET_M0100}, 395 {JapaneseChronology.INSTANCE, JapaneseEra.HEISEI, 1989 - YDIFF_HEISEI, 1, 8, 1, 2, 2, OFFSET_P0100}, 396 {HijrahChronology.INSTANCE, HijrahEra.AH, 1434, 9, 7, 1, 2, 2, OFFSET_P0100}, 397 {MinguoChronology.INSTANCE, MinguoEra.BEFORE_ROC, 1873 - YDIFF_MINGUO, 9, 7, 1, 2, 2, OFFSET_P0100}, 398 {MinguoChronology.INSTANCE, MinguoEra.ROC, 1928 - YDIFF_MINGUO, 2, 28, 1, 2, 2, OFFSET_M0100}, 399 {MinguoChronology.INSTANCE, MinguoEra.ROC, 1989 - YDIFF_MINGUO, 1, 8, 1, 2, 2, OFFSET_P0100}, 400 {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1873 + YDIFF_THAIBUDDHIST, 9, 7, 1, 2, 2, OFFSET_P0100}, 401 {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1928 + YDIFF_THAIBUDDHIST, 2, 28, 1, 2, 2, OFFSET_M0100}, 402 {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1989 + YDIFF_THAIBUDDHIST, 1, 8, 1, 2, 2, OFFSET_P0100}, 403 {IsoChronology.INSTANCE, IsoEra.CE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100}, 404 {IsoChronology.INSTANCE, IsoEra.CE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100}, 405 {IsoChronology.INSTANCE, IsoEra.CE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100}, 406 407 }; 408 } 409 410 @Test(dataProvider = "era_epochSecond_dataProvider") test_epochSecond(Chronology chrono, Era era, int y, int m, int d, int h, int min, int s, ZoneOffset offset)411 public void test_epochSecond(Chronology chrono, Era era, int y, int m, int d, int h, int min, int s, ZoneOffset offset) { 412 ChronoLocalDate chronoLd = chrono.date(era, y, m, d); 413 assertEquals(chrono.epochSecond(era, y, m, d, h, min, s, offset), 414 OffsetDateTime.of(LocalDate.from(chronoLd), LocalTime.of(h, min, s), offset) 415 .toEpochSecond()); 416 } 417 418 @DataProvider(name = "bad_epochSecond_dataProvider") bad_data_epochSecond()419 Object[][] bad_data_epochSecond() { 420 return new Object[][] { 421 {JapaneseChronology.INSTANCE, 1873, 13, 7, 1, 2, 2, OFFSET_P0100}, 422 {HijrahChronology.INSTANCE, 1434, 9, 32, 1, 2, 2, OFFSET_P0100}, 423 {MinguoChronology.INSTANCE, 1873, 9, 7, 31, 2, 2, OFFSET_P0100}, 424 {ThaiBuddhistChronology.INSTANCE, 1928, 2, 28, -1, 2, 2, OFFSET_M0100}, 425 {IsoChronology.INSTANCE, 1928, 2, 28, 1, 60, 2, OFFSET_M0100}, 426 {IsoChronology.INSTANCE, 1989, 1, 8, 1, 2, -2, OFFSET_P0100}, 427 428 }; 429 } 430 431 @Test(dataProvider = "bad_epochSecond_dataProvider", expectedExceptions = DateTimeException.class) test_bad_epochSecond(Chronology chrono, int y, int m, int d, int h, int min, int s, ZoneOffset offset)432 public void test_bad_epochSecond(Chronology chrono, int y, int m, int d, int h, int min, int s, ZoneOffset offset) { 433 chrono.epochSecond(y, m, d, h, min, s, offset); 434 } 435 436 } 437