下面列出了java.time.chrono.ThaiBuddhistDate#of ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void test_periodUntilUnit() {
ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
long months = mdate1.until(mdate2, ChronoUnit.MONTHS);
assertEquals(months, 13);
}
@Test
public void test_periodUntilDiffChrono() {
ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2);
ChronoPeriod period = mdate1.until(ldate2);
assertEquals(period, ThaiBuddhistChronology.INSTANCE.period(1, 1, 1));
}
@DataProvider(name = "calendars")
Object[][] data_of_calendars() {
return new Object[][]{
{JapaneseDate.of(JapaneseEra.HEISEI, 25, 01, 05), JAPANESE_DATE_TYPE},
{MinguoDate.of(102, 01, 05), MINGUO_DATE_TYPE},
{ThaiBuddhistDate.of(2556, 01, 05), THAIBUDDHIST_DATE_TYPE},
};
}
@Test
public void test_periodUntilDiffChrono() {
ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2);
ChronoPeriod period = mdate1.until(ldate2);
assertEquals(period, ThaiBuddhistChronology.INSTANCE.period(1, 1, 1));
}
@Test
public void test_periodUntilDiffChrono() {
ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2);
ChronoPeriod period = mdate1.until(ldate2);
assertEquals(period, ThaiBuddhistChronology.INSTANCE.period(1, 1, 1));
}
@Test
public void test_periodUntilDate() {
ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
ChronoPeriod period = mdate1.until(mdate2);
assertEquals(period, ThaiBuddhistChronology.INSTANCE.period(1, 1, 1));
}
@DataProvider(name="hijrahToThai")
Object[][] data_hijrahToThai() {
return new Object[][] {
{HijrahDate.of(1350,5,15), ThaiBuddhistDate.of(2474,9,28)},
{HijrahDate.of(1434,5,1), ThaiBuddhistDate.of(2556,3,13)},
{HijrahDate.of(1436,1,1), ThaiBuddhistDate.of(2557,10,25)},
{HijrahDate.of(1500,6,12), ThaiBuddhistDate.of(2620,5,5)},
{HijrahDate.of(1550,3,11), ThaiBuddhistDate.of(2668,8,11)},
};
}
@DataProvider(name = "calendars")
Object[][] data_of_calendars() {
return new Object[][]{
{JapaneseDate.of(JapaneseEra.HEISEI, 25, 01, 05), JAPANESE_DATE_TYPE},
{MinguoDate.of(102, 01, 05), MINGUO_DATE_TYPE},
{ThaiBuddhistDate.of(2556, 01, 05), THAIBUDDHIST_DATE_TYPE},
};
}
@DataProvider(name = "calendars")
Object[][] data_of_calendars() {
return new Object[][]{
{JapaneseDate.of(JapaneseEra.HEISEI, 25, 01, 05), JAPANESE_DATE_TYPE},
{MinguoDate.of(102, 01, 05), MINGUO_DATE_TYPE},
{ThaiBuddhistDate.of(2556, 01, 05), THAIBUDDHIST_DATE_TYPE},
};
}
@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},
};
}
@DataProvider(name="zonedDateTime")
Object[][] data_zonedDateTime() {
return new Object[][] {
{ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null},
{OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), HijrahChronology.INSTANCE.date(1433, 4, 7), 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},
};
}
@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},
};
}
@DataProvider(name="zonedDateTime")
Object[][] data_zonedDateTime() {
return new Object[][] {
{ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null},
{OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), HijrahChronology.INSTANCE.date(1433, 4, 7), 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_periodUntilUnit() {
ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
long months = mdate1.until(mdate2, ChronoUnit.MONTHS);
assertEquals(months, 13);
}
@Test
public void test_periodUntilUnit() {
ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
long months = mdate1.until(mdate2, ChronoUnit.MONTHS);
assertEquals(months, 13);
}
@Test
public void test_periodUntilDiffChrono() {
ThaiBuddhistDate mdate1 = ThaiBuddhistDate.of(1, 1, 1);
ThaiBuddhistDate mdate2 = ThaiBuddhistDate.of(2, 2, 2);
MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2);
ChronoPeriod period = mdate1.until(ldate2);
assertEquals(period, ThaiBuddhistChronology.INSTANCE.period(1, 1, 1));
}
@DataProvider(name="localDateTime")
Object[][] data_localDateTime() {
return new Object[][] {
{LocalDateTime.of(2012, 2, 29, 2, 7), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7), null},
{ZonedDateTime.of(2012, 2, 29, 2, 7, 1, 1, ZONE_RIYADH), HijrahChronology.INSTANCE.date(1433, 4, 7), LocalTime.of(2, 7, 1, 1), null},
{OffsetDateTime.of(2012, 2, 29, 2, 7, 1, 1, OFFSET_PTWO), HijrahChronology.INSTANCE.date(1433, 4, 7), 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},
};
}
private static ThaiBuddhistDate date(int y, int m, int d) {
return ThaiBuddhistDate.of(y, m, d);
}
private static ThaiBuddhistDate date(int y, int m, int d) {
return ThaiBuddhistDate.of(y, m, d);
}