Search in sources :

Example 11 with TemporalAmount

use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.

the class TCKLocalTime method test_plus_TemporalAmount_zero.

@Test
public void test_plus_TemporalAmount_zero() {
    TemporalAmount period = Period.ZERO;
    LocalTime t = TEST_12_30_40_987654321.plus(period);
    assertEquals(t, TEST_12_30_40_987654321);
}
Also used : LocalTime(java.time.LocalTime) TemporalAmount(java.time.temporal.TemporalAmount) Test(org.testng.annotations.Test)

Example 12 with TemporalAmount

use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.

the class TCKPeriod method test_minus_TemporalAmount_DaysHours.

@Test(expectedExceptions = DateTimeException.class)
public void test_minus_TemporalAmount_DaysHours() {
    TemporalAmount amount = new TemporalAmount() {

        @Override
        public long get(TemporalUnit unit) {
            if (unit == DAYS) {
                return 1;
            } else {
                return 2;
            }
        }

        @Override
        public List<TemporalUnit> getUnits() {
            List<TemporalUnit> list = new ArrayList<>();
            list.add(DAYS);
            list.add(HOURS);
            return list;
        }

        @Override
        public Temporal addTo(Temporal temporal) {
            throw new UnsupportedOperationException();
        }

        @Override
        public Temporal subtractFrom(Temporal temporal) {
            throw new UnsupportedOperationException();
        }
    };
    pymd(4, 5, 6).minus(amount);
}
Also used : Temporal(java.time.temporal.Temporal) TemporalUnit(java.time.temporal.TemporalUnit) TemporalAmount(java.time.temporal.TemporalAmount) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Example 13 with TemporalAmount

use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.

the class TCKLocalTime method test_minus_TemporalAmount_dateNotAllowed.

@Test(expectedExceptions = DateTimeException.class)
public void test_minus_TemporalAmount_dateNotAllowed() {
    TemporalAmount period = MockSimplePeriod.of(7, ChronoUnit.MONTHS);
    TEST_12_30_40_987654321.minus(period);
}
Also used : TemporalAmount(java.time.temporal.TemporalAmount) Test(org.testng.annotations.Test)

Example 14 with TemporalAmount

use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.

the class TCKLocalTime method test_plus_TemporalAmount_positiveHours.

//-----------------------------------------------------------------------
// plus(TemporalAmount)
//-----------------------------------------------------------------------
@Test
public void test_plus_TemporalAmount_positiveHours() {
    TemporalAmount period = MockSimplePeriod.of(7, ChronoUnit.HOURS);
    LocalTime t = TEST_12_30_40_987654321.plus(period);
    assertEquals(t, LocalTime.of(19, 30, 40, 987654321));
}
Also used : LocalTime(java.time.LocalTime) TemporalAmount(java.time.temporal.TemporalAmount) Test(org.testng.annotations.Test)

Example 15 with TemporalAmount

use of java.time.temporal.TemporalAmount in project jdk8u_jdk by JetBrains.

the class TCKLocalTime method test_plus_TemporalAmount_negativeMinutes.

@Test
public void test_plus_TemporalAmount_negativeMinutes() {
    TemporalAmount period = MockSimplePeriod.of(-25, ChronoUnit.MINUTES);
    LocalTime t = TEST_12_30_40_987654321.plus(period);
    assertEquals(t, LocalTime.of(12, 5, 40, 987654321));
}
Also used : LocalTime(java.time.LocalTime) TemporalAmount(java.time.temporal.TemporalAmount) Test(org.testng.annotations.Test)

Aggregations

TemporalAmount (java.time.temporal.TemporalAmount)25 Test (org.testng.annotations.Test)25 LocalTime (java.time.LocalTime)8 Temporal (java.time.temporal.Temporal)7 TemporalUnit (java.time.temporal.TemporalUnit)7 LocalDate (java.time.LocalDate)6 Chronology (java.time.chrono.Chronology)6 HijrahChronology (java.time.chrono.HijrahChronology)6 IsoChronology (java.time.chrono.IsoChronology)6 JapaneseChronology (java.time.chrono.JapaneseChronology)6 MinguoChronology (java.time.chrono.MinguoChronology)6 ThaiBuddhistChronology (java.time.chrono.ThaiBuddhistChronology)6 ArrayList (java.util.ArrayList)5 ChronoLocalDate (java.time.chrono.ChronoLocalDate)2 Duration (java.time.Duration)1