Search in sources :

Example 56 with OffsetTime

use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.

the class TCKOffsetTime method test_equals_true.

//-----------------------------------------------------------------------
// equals() / hashCode()
//-----------------------------------------------------------------------
@Test(dataProvider = "sampleTimes")
public void test_equals_true(int h, int m, int s, int n, ZoneOffset ignored) {
    OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
    OffsetTime b = OffsetTime.of(h, m, s, n, OFFSET_PONE);
    assertEquals(a.equals(b), true);
    assertEquals(a.hashCode() == b.hashCode(), true);
}
Also used : OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 57 with OffsetTime

use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.

the class TCKOffsetTime method test_equals_false_minute_differs.

@Test(dataProvider = "sampleTimes")
public void test_equals_false_minute_differs(int h, int m, int s, int n, ZoneOffset ignored) {
    m = (m == 59 ? 58 : m);
    OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
    OffsetTime b = OffsetTime.of(h, m + 1, s, n, OFFSET_PONE);
    assertEquals(a.equals(b), false);
}
Also used : OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 58 with OffsetTime

use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.

the class TCKOffsetTime method test_minusSeconds.

//-----------------------------------------------------------------------
// minusSeconds()
//-----------------------------------------------------------------------
@Test
public void test_minusSeconds() {
    OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
    OffsetTime test = base.minusSeconds(60);
    assertEquals(test, OffsetTime.of(11, 29, 59, 0, OFFSET_PONE));
}
Also used : OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 59 with OffsetTime

use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.

the class TCKOffsetTime method now_Clock_offsets.

@Test
public void now_Clock_offsets() {
    Instant base = LocalDateTime.of(1970, 1, 1, 12, 0).toInstant(ZoneOffset.UTC);
    for (int i = -9; i < 15; i++) {
        ZoneOffset offset = ZoneOffset.ofHours(i);
        Clock clock = Clock.fixed(base, offset);
        OffsetTime test = OffsetTime.now(clock);
        assertEquals(test.getHour(), (12 + i) % 24);
        assertEquals(test.getMinute(), 0);
        assertEquals(test.getSecond(), 0);
        assertEquals(test.getNano(), 0);
        assertEquals(test.getOffset(), offset);
    }
}
Also used : OffsetTime(java.time.OffsetTime) Instant(java.time.Instant) Clock(java.time.Clock) ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Example 60 with OffsetTime

use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.

the class TCKOffsetTime method test_minusMinutes_zero.

@Test
public void test_minusMinutes_zero() {
    OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
    OffsetTime test = base.minusMinutes(0);
    assertEquals(test, base);
}
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