@DataProvider(name="prolepticYear") Object[][] data_prolepticYear() { return new Object[][] { {1, MinguoEra.ROC, 1912 - YDIFF, 1912 - YDIFF, true}, {1, MinguoEra.ROC, 1916 - YDIFF, 1916 - YDIFF, true}, {1, MinguoEra.ROC, 1914 - YDIFF, 1914 - YDIFF, false}, {1, MinguoEra.ROC, 2000 - YDIFF, 2000 - YDIFF, true}, {1, MinguoEra.ROC, 2100 - YDIFF, 2100 - YDIFF, false}, {1, MinguoEra.ROC, 0, 0, false}, {1, MinguoEra.ROC, 1908 - YDIFF, 1908 - YDIFF, true}, {1, MinguoEra.ROC, 1900 - YDIFF, 1900 - YDIFF, false}, {1, MinguoEra.ROC, 1600 - YDIFF, 1600 - YDIFF, true}, {0, MinguoEra.BEFORE_ROC, YDIFF - 1911, 1912 - YDIFF, true}, {0, MinguoEra.BEFORE_ROC, YDIFF - 1915, 1916 - YDIFF, true}, {0, MinguoEra.BEFORE_ROC, YDIFF - 1913, 1914 - YDIFF, false}, {0, MinguoEra.BEFORE_ROC, YDIFF - 1999, 2000 - YDIFF, true}, {0, MinguoEra.BEFORE_ROC, YDIFF - 2099, 2100 - YDIFF, false}, {0, MinguoEra.BEFORE_ROC, 1, 0, false}, {0, MinguoEra.BEFORE_ROC, YDIFF - 1907, 1908 - YDIFF, true}, {0, MinguoEra.BEFORE_ROC, YDIFF - 1899, 1900 - YDIFF, false}, {0, MinguoEra.BEFORE_ROC, YDIFF - 1599, 1600 - YDIFF, true}, }; }
@DataProvider(name = "era_epochSecond_dataProvider") Object[][] data_era_epochSecond() { return new Object[][] { {JapaneseChronology.INSTANCE, JapaneseEra.MEIJI, 1873 - YDIFF_MEIJI, 9, 7, 1, 2, 2, OFFSET_P0100}, {JapaneseChronology.INSTANCE, JapaneseEra.SHOWA, 1928 - YDIFF_SHOWA, 2, 28, 1, 2, 2, OFFSET_M0100}, {JapaneseChronology.INSTANCE, JapaneseEra.HEISEI, 1989 - YDIFF_HEISEI, 1, 8, 1, 2, 2, OFFSET_P0100}, {HijrahChronology.INSTANCE, HijrahEra.AH, 1434, 9, 7, 1, 2, 2, OFFSET_P0100}, {MinguoChronology.INSTANCE, MinguoEra.BEFORE_ROC, 1873 - YDIFF_MINGUO, 9, 7, 1, 2, 2, OFFSET_P0100}, {MinguoChronology.INSTANCE, MinguoEra.ROC, 1928 - YDIFF_MINGUO, 2, 28, 1, 2, 2, OFFSET_M0100}, {MinguoChronology.INSTANCE, MinguoEra.ROC, 1989 - YDIFF_MINGUO, 1, 8, 1, 2, 2, OFFSET_P0100}, {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1873 + YDIFF_THAIBUDDHIST, 9, 7, 1, 2, 2, OFFSET_P0100}, {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1928 + YDIFF_THAIBUDDHIST, 2, 28, 1, 2, 2, OFFSET_M0100}, {ThaiBuddhistChronology.INSTANCE, ThaiBuddhistEra.BE, 1989 + YDIFF_THAIBUDDHIST, 1, 8, 1, 2, 2, OFFSET_P0100}, {IsoChronology.INSTANCE, IsoEra.CE, 1873, 9, 7, 1, 2, 2, OFFSET_P0100}, {IsoChronology.INSTANCE, IsoEra.CE, 1928, 2, 28, 1, 2, 2, OFFSET_M0100}, {IsoChronology.INSTANCE, IsoEra.CE, 1989, 1, 8, 1, 2, 2, OFFSET_P0100}, }; }
@DataProvider(name = "MinguoEras") Object[][] data_of_eras() { return new Object[][] { {MinguoEra.BEFORE_ROC, "BEFORE_ROC", 0}, {MinguoEra.ROC, "ROC", 1}, }; }
@Test public void test_MinguoChronology_dateYearDay() { Chronology chrono = Chronology.of("Minguo"); ChronoLocalDate date1 = chrono.dateYearDay(MinguoEra.ROC, 5, 60); ChronoLocalDate date2 = chrono.date(MinguoEra.ROC, 5, 2, 29); assertEquals(date1, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60)); assertEquals(date2, MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 5, 60)); }
@DataProvider(name="samples") Object[][] data_samples() { return new Object[][] { {MinguoChronology.INSTANCE.date(1, 1, 1), LocalDate.of(1 + YDIFF, 1, 1)}, {MinguoChronology.INSTANCE.date(1, 1, 2), LocalDate.of(1 + YDIFF, 1, 2)}, {MinguoChronology.INSTANCE.date(1, 1, 3), LocalDate.of(1 + YDIFF, 1, 3)}, {MinguoChronology.INSTANCE.date(2, 1, 1), LocalDate.of(2 + YDIFF, 1, 1)}, {MinguoChronology.INSTANCE.date(3, 1, 1), LocalDate.of(3 + YDIFF, 1, 1)}, {MinguoChronology.INSTANCE.date(3, 12, 6), LocalDate.of(3 + YDIFF, 12, 6)}, {MinguoChronology.INSTANCE.date(4, 1, 1), LocalDate.of(4 + YDIFF, 1, 1)}, {MinguoChronology.INSTANCE.date(4, 7, 3), LocalDate.of(4 + YDIFF, 7, 3)}, {MinguoChronology.INSTANCE.date(4, 7, 4), LocalDate.of(4 + YDIFF, 7, 4)}, {MinguoChronology.INSTANCE.date(5, 1, 1), LocalDate.of(5 + YDIFF, 1, 1)}, {MinguoChronology.INSTANCE.date(100, 3, 3), LocalDate.of(100 + YDIFF, 3, 3)}, {MinguoChronology.INSTANCE.date(101, 10, 28), LocalDate.of(101 + YDIFF, 10, 28)}, {MinguoChronology.INSTANCE.date(101, 10, 29), LocalDate.of(101 + YDIFF, 10, 29)}, {MinguoChronology.INSTANCE.dateYearDay(1916 - YDIFF, 60), LocalDate.of(1916, 2, 29)}, {MinguoChronology.INSTANCE.dateYearDay(1908 - YDIFF, 60), LocalDate.of(1908, 2, 29)}, {MinguoChronology.INSTANCE.dateYearDay(2000 - YDIFF, 60), LocalDate.of(2000, 2, 29)}, {MinguoChronology.INSTANCE.dateYearDay(2400 - YDIFF, 60), LocalDate.of(2400, 2, 29)}, {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 1916 - YDIFF, 60), LocalDate.of(1916, 2, 29)}, {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.BEFORE_ROC, 4, 60), LocalDate.of(1908, 2, 29)}, {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 2000 - YDIFF, 60), LocalDate.of(2000, 2, 29)}, {MinguoChronology.INSTANCE.dateYearDay(MinguoEra.ROC, 2400 - YDIFF, 60), LocalDate.of(2400, 2, 29)}, {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1916 - YDIFF, 2, 29 ), LocalDate.of(1916, 2, 29)}, {MinguoChronology.INSTANCE.date(MinguoEra.BEFORE_ROC, 4, 2, 29), LocalDate.of(1908, 2, 29)}, {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2000 - YDIFF, 2, 29), LocalDate.of(2000, 2, 29)}, {MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2400 - YDIFF, 2, 29), LocalDate.of(2400, 2, 29)}, }; }
@Test() public void test_MinguoChrono() { MinguoDate h1 = MinguoChronology.INSTANCE.date(MinguoEra.ROC, 1, 2, 3); MinguoDate h2 = h1; ChronoLocalDateTime<MinguoDate> h3 = h2.atTime(LocalTime.NOON); @SuppressWarnings("unused") ChronoZonedDateTime<MinguoDate> h4 = h3.atZone(ZoneOffset.UTC); }
@DataProvider(name="localDateTime") Object[][] data_localDateTime() { return new Object[][] { {LocalDateTime.of(2012, 2, 29, 2, 7), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7), null}, {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class}, {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class}, {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class}, {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class}, }; }
@DataProvider(name="zonedDateTime") Object[][] data_zonedDateTime() { return new Object[][] { {ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, {OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29), LocalTime.of(2, 7, 1, 1), null}, {LocalDateTime.of(2012, 2, 29, 2, 7), null, null, DateTimeException.class}, {JapaneseDate.of(2012, 2, 29), null, null, DateTimeException.class}, {ThaiBuddhistDate.of(2012 + 543, 2, 29), null, null, DateTimeException.class}, {LocalDate.of(2012, 2, 29), null, null, DateTimeException.class}, {LocalTime.of(20, 30, 29, 0), null, null, DateTimeException.class}, }; }
@Test public void test_Instant_zonedDateTime() { OffsetDateTime offsetDateTime = OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO); ZonedDateTime zonedDateTime = ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_PARIS); ChronoZonedDateTime<MinguoDate> result = MinguoChronology.INSTANCE.zonedDateTime(offsetDateTime.toInstant(), offsetDateTime.getOffset()); assertEquals(result.toLocalDate(), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29)); assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1)); result = MinguoChronology.INSTANCE.zonedDateTime(zonedDateTime.toInstant(), zonedDateTime.getOffset()); assertEquals(result.toLocalDate(), MinguoChronology.INSTANCE.date(MinguoEra.ROC, 2012 - YDIFF, 2, 29)); assertEquals(result.toLocalTime(), LocalTime.of(2, 7, 1, 1)); }
@DataProvider(name = "Eras") Era[][] data_of_calendars() { return new Era[][] { {HijrahEra.AH}, {IsoEra.BCE}, {IsoEra.CE}, {MinguoEra.BEFORE_ROC}, {MinguoEra.ROC}, {ThaiBuddhistEra.BEFORE_BE}, {ThaiBuddhistEra.BE}, }; }