Search in sources :

Example 36 with ChronoPeriod

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

the class TCKChronoPeriod method test_multipliedBy.

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

Example 37 with ChronoPeriod

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

the class TCKChronoPeriod method test_plus.

//-----------------------------------------------------------------------
@Test(dataProvider = "calendars")
public void test_plus(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    ChronoPeriod period2 = chrono.period(2, 3, 4);
    ChronoPeriod result = period.plus(period2);
    assertEquals(result, chrono.period(3, 5, 7));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) Test(org.testng.annotations.Test)

Example 38 with ChronoPeriod

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

the class TCKChronoPeriod method test_subtractFrom_wrongChrono.

@Test(dataProvider = "calendars", expectedExceptions = DateTimeException.class)
public void test_subtractFrom_wrongChrono(Chronology chrono) {
    ChronoPeriod period = chrono.period(1, 2, 3);
    ChronoLocalDate isoDate = LocalDate.of(2000, 1, 1);
    ChronoLocalDate thaiDate = ThaiBuddhistChronology.INSTANCE.date(2000, 1, 1);
    // one of these two will fail
    period.subtractFrom(isoDate);
    period.subtractFrom(thaiDate);
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) ChronoLocalDate(java.time.chrono.ChronoLocalDate) Test(org.testng.annotations.Test)

Example 39 with ChronoPeriod

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

the class TCKMinguoChronology method test_periodUntilDiffChrono.

@Test
public void test_periodUntilDiffChrono() {
    MinguoDate mdate1 = MinguoDate.of(1970, 1, 1);
    MinguoDate mdate2 = MinguoDate.of(1971, 2, 2);
    ThaiBuddhistDate ldate2 = ThaiBuddhistChronology.INSTANCE.date(mdate2);
    ChronoPeriod period = mdate1.until(ldate2);
    assertEquals(period, MinguoChronology.INSTANCE.period(1, 1, 1));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) MinguoDate(java.time.chrono.MinguoDate) ThaiBuddhistDate(java.time.chrono.ThaiBuddhistDate) Test(org.testng.annotations.Test)

Example 40 with ChronoPeriod

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

the class TCKJapaneseChronology method test_periodUntilDiffChrono.

@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));
}
Also used : ChronoPeriod(java.time.chrono.ChronoPeriod) MinguoDate(java.time.chrono.MinguoDate) JapaneseDate(java.time.chrono.JapaneseDate) 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