Search in sources :

Example 66 with OffsetTime

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

Example 67 with OffsetTime

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

Example 68 with OffsetTime

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

Example 69 with OffsetTime

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

Example 70 with OffsetTime

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);
}
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