use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_withOffsetSameLocal.
//-----------------------------------------------------------------------
// withOffsetSameLocal()
//-----------------------------------------------------------------------
@Test
public void test_withOffsetSameLocal() {
OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
OffsetTime test = base.withOffsetSameLocal(OFFSET_PTWO);
assertEquals(test.toLocalTime(), base.toLocalTime());
assertEquals(test.getOffset(), OFFSET_PTWO);
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_with_adjuster_OffsetTime_invalidOffsetIgnored1.
@Test
public void test_with_adjuster_OffsetTime_invalidOffsetIgnored1() {
// OT has invalid offset for ZDT, so only LT is set
OffsetTime ot = OffsetTime.of(0, 50, 30, 40, OFFSET_0130);
// earlier part of overlap
ZonedDateTime zdt = dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS);
ZonedDateTime test = zdt.with(ot);
assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 0, 50, 30, 40));
// offset not adjusted
assertEquals(test.getOffset(), OFFSET_0200);
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_with_adjuster_OffsetTime_validOffsetIntoOverlap2.
@Test
public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap2() {
// OT has valid offset for resulting time
// valid offset in overlap
OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0200);
// just before overlap
ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS);
ZonedDateTime test = zdt.with(ot);
assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40));
assertEquals(test.getOffset(), OFFSET_0200);
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_with_adjuster_OffsetTime_validOffsetIntoOverlap1.
@Test
public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap1() {
// OT has valid offset for resulting time
// valid offset in overlap
OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0100);
// just before overlap
ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS);
ZonedDateTime test = zdt.with(ot);
assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40));
assertEquals(test.getOffset(), OFFSET_0100);
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_compareTo_bothNearStartOfDay.
@Test
public void test_compareTo_bothNearStartOfDay() {
OffsetTime a = OffsetTime.of(0, 10, 0, 0, OFFSET_PONE);
// a is before b on instant scale
OffsetTime b = OffsetTime.of(2, 30, 0, 0, OFFSET_PTWO);
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(convertInstant(a).compareTo(convertInstant(b)) < 0, true);
}
Aggregations