use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method now_Clock_beforeEpoch.
@Test
public void now_Clock_beforeEpoch() {
for (int i = -1; i >= -(24 * 60 * 60); i--) {
Instant instant = Instant.ofEpochSecond(i, 8);
Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
OffsetTime test = OffsetTime.now(clock);
assertEquals(test.getHour(), ((i + 24 * 60 * 60) / (60 * 60)) % 24);
assertEquals(test.getMinute(), ((i + 24 * 60 * 60) / 60) % 60);
assertEquals(test.getSecond(), (i + 24 * 60 * 60) % 60);
assertEquals(test.getNano(), 8);
assertEquals(test.getOffset(), ZoneOffset.UTC);
}
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_with_adjustment.
//-----------------------------------------------------------------------
// with(WithAdjuster)
//-----------------------------------------------------------------------
@Test
public void test_with_adjustment() {
final OffsetTime sample = OffsetTime.of(23, 5, 0, 0, OFFSET_PONE);
TemporalAdjuster adjuster = new TemporalAdjuster() {
@Override
public Temporal adjustInto(Temporal dateTime) {
return sample;
}
};
assertEquals(TEST_11_30_59_500_PONE.with(adjuster), sample);
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_isBeforeIsAfterIsEqual_instantComparison.
@Test
public void test_isBeforeIsAfterIsEqual_instantComparison() {
OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PTWO);
// a is same instant as b
OffsetTime b = OffsetTime.of(10, 30, 59, 0, OFFSET_PONE);
assertEquals(a.isBefore(b), false);
assertEquals(a.isEqual(b), true);
assertEquals(a.isAfter(b), false);
assertEquals(b.isBefore(a), false);
assertEquals(b.isEqual(a), true);
assertEquals(b.isAfter(a), false);
assertEquals(a.isBefore(a), false);
assertEquals(b.isBefore(b), false);
assertEquals(a.isEqual(a), true);
assertEquals(b.isEqual(b), true);
assertEquals(a.isAfter(a), false);
assertEquals(b.isAfter(b), false);
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_isBeforeIsAfterIsEqual1.
//-----------------------------------------------------------------------
// isAfter() / isBefore() / isEqual()
//-----------------------------------------------------------------------
@Test
public void test_isBeforeIsAfterIsEqual1() {
OffsetTime a = OffsetTime.of(11, 30, 58, 0, OFFSET_PONE);
// a is before b due to time
OffsetTime b = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
assertEquals(a.isBefore(b), true);
assertEquals(a.isEqual(b), false);
assertEquals(a.isAfter(b), false);
assertEquals(b.isBefore(a), false);
assertEquals(b.isEqual(a), false);
assertEquals(b.isAfter(a), true);
assertEquals(a.isBefore(a), false);
assertEquals(b.isBefore(b), false);
assertEquals(a.isEqual(a), true);
assertEquals(b.isEqual(b), true);
assertEquals(a.isAfter(a), false);
assertEquals(b.isAfter(b), false);
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_withOffsetSameInstant_null.
@Test(expectedExceptions = NullPointerException.class)
public void test_withOffsetSameInstant_null() {
OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
base.withOffsetSameInstant(null);
}
Aggregations