Search in sources :

Example 61 with OffsetTime

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

the class TCKOffsetTime method factory_parse_formatter.

//-----------------------------------------------------------------------
// parse(DateTimeFormatter)
//-----------------------------------------------------------------------
@Test
public void factory_parse_formatter() {
    DateTimeFormatter f = DateTimeFormatter.ofPattern("H m s XXX");
    OffsetTime test = OffsetTime.parse("11 30 0 +01:00", f);
    assertEquals(test, OffsetTime.of(11, 30, 0, 0, ZoneOffset.ofHours(1)));
}
Also used : OffsetTime(java.time.OffsetTime) DateTimeFormatter(java.time.format.DateTimeFormatter) Test(org.testng.annotations.Test)

Example 62 with OffsetTime

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

the class TCKOffsetTime method test_getLong_TemporalField.

@Test
public void test_getLong_TemporalField() {
    OffsetTime test = OffsetTime.of(12, 30, 40, 987654321, OFFSET_PONE);
    assertEquals(test.getLong(ChronoField.HOUR_OF_DAY), 12);
    assertEquals(test.getLong(ChronoField.MINUTE_OF_HOUR), 30);
    assertEquals(test.getLong(ChronoField.SECOND_OF_MINUTE), 40);
    assertEquals(test.getLong(ChronoField.NANO_OF_SECOND), 987654321);
    assertEquals(test.getLong(ChronoField.HOUR_OF_AMPM), 0);
    assertEquals(test.getLong(ChronoField.AMPM_OF_DAY), 1);
    assertEquals(test.getLong(ChronoField.OFFSET_SECONDS), 3600);
}
Also used : OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 63 with OffsetTime

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

the class TCKOffsetTime method test_with_adjustment_AmPm.

@Test
public void test_with_adjustment_AmPm() {
    OffsetTime test = TEST_11_30_59_500_PONE.with(new TemporalAdjuster() {

        @Override
        public Temporal adjustInto(Temporal dateTime) {
            return dateTime.with(HOUR_OF_DAY, 23);
        }
    });
    assertEquals(test, OffsetTime.of(23, 30, 59, 500, OFFSET_PONE));
}
Also used : Temporal(java.time.temporal.Temporal) OffsetTime(java.time.OffsetTime) TemporalAdjuster(java.time.temporal.TemporalAdjuster) Test(org.testng.annotations.Test)

Example 64 with OffsetTime

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

the class TCKOffsetTime method test_compareTo_both.

@Test
public void test_compareTo_both() {
    OffsetTime a = OffsetTime.of(11, 50, 0, 0, OFFSET_PTWO);
    // a is before b on instant scale
    OffsetTime b = OffsetTime.of(11, 20, 0, 0, OFFSET_PONE);
    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)

Example 65 with OffsetTime

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

the class TCKOffsetTime method test_plusHours_zero.

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