Search in sources :

Example 1 with ChronoPeriod

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

the class TestUmmAlQuraChronology method test_periodUntilDiffChrono.

// Test to get the Period between dates in different chronologies
@Test(dataProvider = "datesForPeriod")
public void test_periodUntilDiffChrono(HijrahDate h1, HijrahDate h2, ChronoPeriod p) {
    MinguoDate m = MinguoChronology.INSTANCE.date(h2);
    ChronoPeriod period = h1.until(m);
    assertEquals(period, p);
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) MinguoDate(java.time.chrono.MinguoDate) Test(org.testng.annotations.Test)

Example 2 with ChronoPeriod

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

the class TCKThaiBuddhistChronology method test_periodUntilDiffChrono.

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

Example 3 with ChronoPeriod

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

the class TCKChronoPeriod method test_minus_wrongChrono.

@Test(dataProvider = "calendars", expectedExceptions = DateTimeException.class)
public void test_minus_wrongChrono(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    ChronoPeriod isoPeriod = Period.of(2, 3, 4);
    ChronoPeriod thaiPeriod = ThaiBuddhistChronology.INSTANCE.period(2, 3, 4);
    // one of these two will fail
    period.minus(isoPeriod);
    period.minus(thaiPeriod);
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) Test(org.testng.annotations.Test)

Example 4 with ChronoPeriod

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

the class TCKChronoPeriod method test_getChronology.

@Test(dataProvider = "calendars")
public void test_getChronology(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    assertEquals(period.getChronology(), chrono);
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) Test(org.testng.annotations.Test)

Example 5 with ChronoPeriod

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

the class TCKChronoPeriod method test_getUnits.

@Test(dataProvider = "calendars")
public void test_getUnits(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    assertEquals(period.getUnits().size(), 3);
    assertEquals(period.getUnits().get(0), YEARS);
    assertEquals(period.getUnits().get(1), MONTHS);
    assertEquals(period.getUnits().get(2), DAYS);
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) Test(org.testng.annotations.Test)

Aggregations

ChronoPeriod (java.time.chrono.ChronoPeriod)55 Test (org.testng.annotations.Test)26 Test (org.junit.Test)21 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)14 ChronoLocalDate (java.time.chrono.ChronoLocalDate)6 MinguoDate (java.time.chrono.MinguoDate)5 List (java.util.List)5 BigDecimal (java.math.BigDecimal)4 Period (java.time.Period)4 ChronoUnit (java.time.temporal.ChronoUnit)4 Temporal (java.time.temporal.Temporal)4 TemporalAccessor (java.time.temporal.TemporalAccessor)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4 Predicate (java.util.function.Predicate)4 Before (org.junit.Before)4 ComparablePeriod (org.kie.dmn.feel.lang.types.impl.ComparablePeriod)4 Duration (java.time.Duration)3 ThaiBuddhistDate (java.time.chrono.ThaiBuddhistDate)3 TemporalUnit (java.time.temporal.TemporalUnit)3