use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_compareTo_offset.
@Test
public void test_compareTo_offset() {
OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
// a is before b due to offset
OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PONE);
assertEquals(a.compareTo(b) < 0, true);
assertEquals(b.compareTo(a) > 0, true);
assertEquals(a.compareTo(a) == 0, true);
assertEquals(b.compareTo(b) == 0, true);
assertEquals(a.toInstant().compareTo(b.toInstant()) < 0, true);
assertEquals(OffsetDateTime.timeLineOrder().compare(a, b) < 0, true);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_compareTo_max.
@Test
public void test_compareTo_max() {
OffsetDateTime a = OffsetDateTime.of(Year.MAX_VALUE, 12, 31, 23, 59, 0, 0, OFFSET_MONE);
// a is before b due to offset
OffsetDateTime b = OffsetDateTime.of(Year.MAX_VALUE, 12, 31, 23, 59, 0, 0, OFFSET_MTWO);
assertEquals(a.compareTo(b) < 0, true);
assertEquals(b.compareTo(a) > 0, true);
assertEquals(a.compareTo(a) == 0, true);
assertEquals(b.compareTo(b) == 0, true);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_withNanoOfSecond_normal.
//-----------------------------------------------------------------------
// withNano()
//-----------------------------------------------------------------------
@Test
public void test_withNanoOfSecond_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
OffsetDateTime test = base.withNano(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_plus_Period.
//-----------------------------------------------------------------------
// plus(Period)
//-----------------------------------------------------------------------
@Test
public void test_plus_Period() {
MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS);
OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(period);
assertEquals(t, OffsetDateTime.of(2009, 1, 30, 11, 30, 59, 500, OFFSET_PONE));
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_plusYears.
//-----------------------------------------------------------------------
// plusYears()
//-----------------------------------------------------------------------
@Test
public void test_plusYears() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
OffsetDateTime test = base.plusYears(1);
assertEquals(test, OffsetDateTime.of(2009, 6, 30, 11, 30, 59, 0, OFFSET_PONE));
}
Aggregations