Search in sources :

Example 21 with JapaneseDate

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

the class TCKJapaneseChronology method test_resolve_yearOfEra_eraAndYearOnly_valid.

@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraAndYearOnly_valid(ResolverStyle style, JapaneseEra era) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.ERA, (long) era.getValue());
    fieldValues.put(ChronoField.YEAR, 1L);
    JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
    assertEquals(date, null);
    assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue());
    assertEquals(fieldValues.get(ChronoField.YEAR), (Long) 1L);
    assertEquals(fieldValues.size(), 2);
}
Also used : TemporalField(java.time.temporal.TemporalField) HashMap(java.util.HashMap) JapaneseDate(java.time.chrono.JapaneseDate) Test(org.testng.annotations.Test)

Example 22 with JapaneseDate

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

the class TCKJapaneseChronology method test_with_TemporalField_long.

//-----------------------------------------------------------------------
// with(TemporalField, long)
//-----------------------------------------------------------------------
@Test
public void test_with_TemporalField_long() {
    JapaneseDate base = JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 63, 6, 30);
    JapaneseDate test = base.with(YEAR, 1987);
    assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 62, 6, 30));
    test = test.with(YEAR_OF_ERA, 2);
    assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.SHOWA, 2, 6, 30));
    test = test.with(ERA, JapaneseEra.HEISEI.getValue());
    assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 6, 30));
    test = test.with(MONTH_OF_YEAR, 3);
    assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 30));
    test = test.with(DAY_OF_MONTH, 4);
    assertEquals(test, JapaneseChronology.INSTANCE.date(JapaneseEra.HEISEI, 2, 3, 4));
}
Also used : JapaneseDate(java.time.chrono.JapaneseDate) Test(org.testng.annotations.Test)

Example 23 with JapaneseDate

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

the class TCKJapaneseChronology method test_periodUntilDate.

//-----------------------------------------------------------------------
// PeriodUntil()
//-----------------------------------------------------------------------
@Test
public void test_periodUntilDate() {
    JapaneseDate mdate1 = JapaneseDate.of(1970, 1, 1);
    JapaneseDate mdate2 = JapaneseDate.of(1971, 2, 2);
    ChronoPeriod period = mdate1.until(mdate2);
    assertEquals(period, JapaneseChronology.INSTANCE.period(1, 1, 1));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) JapaneseDate(java.time.chrono.JapaneseDate) Test(org.testng.annotations.Test)

Example 24 with JapaneseDate

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

the class TCKJapaneseChronology method test_resolve_yearOfEra_eraOnly_valid.

@Test(dataProvider = "resolve_styleByEra")
public void test_resolve_yearOfEra_eraOnly_valid(ResolverStyle style, JapaneseEra era) {
    Map<TemporalField, Long> fieldValues = new HashMap<>();
    fieldValues.put(ChronoField.ERA, (long) era.getValue());
    JapaneseDate date = JapaneseChronology.INSTANCE.resolveDate(fieldValues, style);
    assertEquals(date, null);
    assertEquals(fieldValues.get(ChronoField.ERA), (Long) (long) era.getValue());
    assertEquals(fieldValues.size(), 1);
}
Also used : TemporalField(java.time.temporal.TemporalField) HashMap(java.util.HashMap) JapaneseDate(java.time.chrono.JapaneseDate) Test(org.testng.annotations.Test)

Example 25 with JapaneseDate

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

the class TCKJapaneseChronology method test_createByEra_epochDay.

@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());
}
Also used : 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