Search in sources :

Example 91 with OffsetTime

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

the class TCKOffsetTime method test_equals_false_nano_differs.

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

Example 92 with OffsetTime

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

the class TCKOffsetTime method now_Clock_allSecsInDay.

//-----------------------------------------------------------------------
// now(Clock)
//-----------------------------------------------------------------------
@Test
public void now_Clock_allSecsInDay() {
    for (int i = 0; i < (2 * 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 / (60 * 60)) % 24);
        assertEquals(test.getMinute(), (i / 60) % 60);
        assertEquals(test.getSecond(), i % 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 93 with OffsetTime

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

the class TCKOffsetTime method test_toString.

@Test(dataProvider = "sampleToString")
public void test_toString(int h, int m, int s, int n, String offsetId, String expected) {
    OffsetTime t = OffsetTime.of(h, m, s, n, ZoneOffset.of(offsetId));
    String str = t.toString();
    assertEquals(str, expected);
}
Also used : OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 94 with OffsetTime

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

the class TCKOffsetTime method test_equals_false_offset_differs.

@Test(dataProvider = "sampleTimes")
public void test_equals_false_offset_differs(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_PTWO);
    assertEquals(a.equals(b), false);
}
Also used : OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 95 with OffsetTime

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

the class TCKOffsetTime method factory_ofInstant_maxYear.

//-----------------------------------------------------------------------
@Test
public void factory_ofInstant_maxYear() {
    OffsetTime test = OffsetTime.ofInstant(Instant.MAX, ZoneOffset.UTC);
    assertEquals(test.getHour(), 23);
    assertEquals(test.getMinute(), 59);
    assertEquals(test.getSecond(), 59);
    assertEquals(test.getNano(), 999_999_999);
}
Also used : OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Aggregations

OffsetTime (java.time.OffsetTime)95 Test (org.testng.annotations.Test)86 ZonedDateTime (java.time.ZonedDateTime)8 Instant (java.time.Instant)7 LocalTime (java.time.LocalTime)7 Time (java.sql.Time)6 OffsetDateTime (java.time.OffsetDateTime)6 LocalDate (java.time.LocalDate)5 LocalDateTime (java.time.LocalDateTime)5 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 DateTimeFormatter (java.time.format.DateTimeFormatter)2 Temporal (java.time.temporal.Temporal)2 TemporalAdjuster (java.time.temporal.TemporalAdjuster)2 UUID (java.util.UUID)2