Search in sources :

Example 16 with JapaneseDate

use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.

the class TCKJapaneseChronology method test_createByEra_dateFrom.

@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);
}
Also used : JapaneseDate(java.time.chrono.JapaneseDate) Test(org.testng.annotations.Test)

Example 17 with JapaneseDate

use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.

the class TCKJapaneseChronology method test_LocalDate_adjustToJapaneseDate.

//-----------------------------------------------------------------------
// LocalDate.with(JapaneseDate)
//-----------------------------------------------------------------------
@Test
public void test_LocalDate_adjustToJapaneseDate() {
    JapaneseDate jdate = JapaneseChronology.INSTANCE.date(1928, 10, 29);
    LocalDate test = LocalDate.MIN.with(jdate);
    assertEquals(test, LocalDate.of(1928, 10, 29));
}
Also used : JapaneseDate(java.time.chrono.JapaneseDate) ChronoLocalDate(java.time.chrono.ChronoLocalDate) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 18 with JapaneseDate

use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.

the class TCKJapaneseChronology method test_resolve_yd_smart.

@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_smart(int y, int d, JapaneseDate expected, boolean smart, boolean strict) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.YEAR, (long) y);
    fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
    if (smart) {
        JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            JapaneseChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.SMART);
            fail("Should have failed");
        } catch (DateTimeException ex) {
        // expected
        }
    }
}
Also used : TemporalField(java.time.temporal.TemporalField) DateTimeException(java.time.DateTimeException) HashMap(java.util.HashMap) JapaneseDate(java.time.chrono.JapaneseDate) Test(org.testng.annotations.Test)

Example 19 with JapaneseDate

use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.

the class TCKJapaneseChronology method test_createByProleptic_query.

@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);
}
Also used : JapaneseDate(java.time.chrono.JapaneseDate) Test(org.testng.annotations.Test)

Example 20 with JapaneseDate

use of java.time.chrono.JapaneseDate in project jdk8u_jdk by JetBrains.

the class TCKJapaneseChronology method test_resolve_eymd.

@Test(dataProvider = "resolve_eymd")
public void test_resolve_eymd(ResolverStyle style, JapaneseEra era, int yoe, int m, int d, JapaneseDate expected) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.ERA, (long) era.getValue());
    fieldValues.put(ChronoField.YEAR_OF_ERA, (long) yoe);
    fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
    fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
    if (expected != null) {
        JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
        assertEquals(date, expected);
        assertEquals(fieldValues.size(), 0);
    } else {
        try {
            JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
            fail("Should have failed");
        } catch (DateTimeException ex) {
        // expected
        }
    }
}
Also used : TemporalField(java.time.temporal.TemporalField) DateTimeException(java.time.DateTimeException) HashMap(java.util.HashMap) JapaneseDate(java.time.chrono.JapaneseDate) Test(org.testng.annotations.Test)

Aggregations

JapaneseDate (java.time.chrono.JapaneseDate)42 Test (org.testng.annotations.Test)42 TemporalField (java.time.temporal.TemporalField)12 HashMap (java.util.HashMap)12 DateTimeException (java.time.DateTimeException)5 OffsetDateTime (java.time.OffsetDateTime)2 ChronoPeriod (java.time.chrono.ChronoPeriod)2 JapaneseEra (java.time.chrono.JapaneseEra)2 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 Locale (java.util.Locale)2 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 ChronoLocalDate (java.time.chrono.ChronoLocalDate)1 MinguoDate (java.time.chrono.MinguoDate)1 ValueRange (java.time.temporal.ValueRange)1