Search in sources :

Example 81 with OffsetTime

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);
}
Also used : OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 82 with OffsetTime

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);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 83 with OffsetTime

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);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 84 with OffsetTime

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);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 85 with OffsetTime

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);
}
Also used : OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Aggregations

OffsetTime (java.time.OffsetTime)99 Test (org.testng.annotations.Test)86 ZonedDateTime (java.time.ZonedDateTime)9 LocalTime (java.time.LocalTime)8 Instant (java.time.Instant)7 OffsetDateTime (java.time.OffsetDateTime)7 Time (java.sql.Time)6 LocalDate (java.time.LocalDate)6 LocalDateTime (java.time.LocalDateTime)6 Test (org.junit.Test)6 Date (java.sql.Date)3 ResultSet (java.sql.ResultSet)3 Clock (java.time.Clock)3 PostgresUtils.toPGArrayString (org.jooq.util.postgres.PostgresUtils.toPGArrayString)3 BigDecimal (java.math.BigDecimal)2 PreparedStatement (java.sql.PreparedStatement)2 Timestamp (java.sql.Timestamp)2 Duration (java.time.Duration)2 Period (java.time.Period)2 ZoneId (java.time.ZoneId)2