Java Code Examples for java.time.chrono.JapaneseDate#of()

The following examples show how to use java.time.chrono.JapaneseDate#of() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKJapaneseChronology.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_periodUntilUnit() {
    JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1);
    JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2);
    long months = mdate1.until(mdate2, ChronoUnit.MONTHS);
    assertEquals(months, 13);
}
 
Example 2
Source File: TCKMinguoChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 3
Source File: TCKJapaneseChronology.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_periodUntilDiffChrono() {
    JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1);
    JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2);
    MinguoDate ldate2 = MinguoChronology.INSTANCE.date(mdate2);
    ChronoPeriod period = mdate1.until(ldate2);
    assertEquals(period, JapaneseChronology.INSTANCE.period(1, 1, 1));
}
 
Example 4
Source File: TCKMinguoChronology.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 5
Source File: TCKMinguoChronology.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 6
Source File: TCKChronoLocalDateSerialization.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 7
Source File: TCKJapaneseChronology.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_periodUntilUnit() {
    JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1);
    JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2);
    long months = mdate1.until(mdate2, ChronoUnit.MONTHS);
    assertEquals(months, 13);
}
 
Example 8
Source File: TCKMinguoChronology.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 9
Source File: TCKChronoLocalDateSerialization.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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},
    };
}
 
Example 10
Source File: TCKJapaneseChronology.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="createByEra")
public void test_createEymd(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate dateByChronoFactory = JapaneseChronology.INSTANCE.date(era, yoe, moy, dom);
    JapaneseDate dateByDateFactory = JapaneseDate.of(era, yoe, moy, dom);
    assertEquals(dateByChronoFactory, dateByDateFactory);
    assertEquals(dateByChronoFactory.hashCode(), dateByDateFactory.hashCode());
}
 
Example 11
Source File: TCKJapaneseChronology.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="createByProleptic")
public void test_createByProleptic_query(int y, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate test = JapaneseDate.of(y, moy, dom);
    assertEquals(test.query(TemporalQueries.localDate()), iso);
}
 
Example 12
Source File: TCKJapaneseChronology.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="createByEra")
public void test_createByEra_dateFrom(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
    assertEquals(LocalDate.from(test), iso);
    assertEquals(JapaneseDate.from(iso), test);
}
 
Example 13
Source File: TCKJapaneseChronology.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="createByEra")
public void test_createByEra_chronologyTemporalFactory(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
    assertEquals(IsoChronology.INSTANCE.date(test), iso);
    assertEquals(JapaneseChronology.INSTANCE.date(iso), test);
}
 
Example 14
Source File: TCKJapaneseChronology.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="createByProleptic")
public void test_createByProleptic_chronologyTemporalFactory(int y, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate test = JapaneseDate.of(y, moy, dom);
    assertEquals(IsoChronology.INSTANCE.date(test), iso);
    assertEquals(JapaneseChronology.INSTANCE.date(iso), test);
}
 
Example 15
Source File: TCKJapaneseChronology.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="createByEra")
public void test_createByEra_epochDay(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
    assertEquals(test.getLong(EPOCH_DAY), iso.getLong(EPOCH_DAY));
    assertEquals(test.toEpochDay(), iso.toEpochDay());
}
 
Example 16
Source File: TCKJapaneseChronology.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="createByProleptic")
public void test_createByProleptic_epochDay(int y, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate test = JapaneseDate.of(y, moy, dom);
    assertEquals(test.getLong(EPOCH_DAY), iso.getLong(EPOCH_DAY));
    assertEquals(test.toEpochDay(), iso.toEpochDay());
}
 
Example 17
Source File: TCKJapaneseChronology.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="createByProleptic")
public void test_createByProleptic_dateFrom(int y, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate test = JapaneseDate.of(y, moy, dom);
    assertEquals(LocalDate.from(test), iso);
    assertEquals(JapaneseDate.from(iso), test);
}
 
Example 18
Source File: TCKJapaneseChronology.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="createByEra")
public void test_createByEra_query(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
    assertEquals(test.query(TemporalQueries.localDate()), iso);
}
 
Example 19
Source File: TCKJapaneseChronology.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="createByProleptic")
public void test_createByProleptic_epochDay(int y, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate test = JapaneseDate.of(y, moy, dom);
    assertEquals(test.getLong(EPOCH_DAY), iso.getLong(EPOCH_DAY));
    assertEquals(test.toEpochDay(), iso.toEpochDay());
}
 
Example 20
Source File: TCKJapaneseChronology.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="createByEra")
public void test_createByEra_dateFrom(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) {
    JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom);
    assertEquals(LocalDate.from(test), iso);
    assertEquals(JapaneseDate.from(iso), test);
}