java.time.OffsetTime Java Examples

The following examples show how to use java.time.OffsetTime. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TCKOffsetTime.java    From j2objc with Apache License 2.0 6 votes vote down vote up
@Test
public void test_isBeforeIsAfterIsEqual2() {
    OffsetTime a = OffsetTime.of(11, 30, 59, 0, OFFSET_PTWO);
    OffsetTime b = OffsetTime.of(11, 30, 58, 0, OFFSET_PONE);  // a is before b due to offset
    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);
}
 
Example #2
Source File: StatementsTest.java    From r-course with MIT License 6 votes vote down vote up
/**
 * Helper method for *SetObject* tests.
 * Validate the test data contained in the given ResultSet with following structure:
 * 1 - `id` INT
 * 2 - `ot1` VARCHAR
 * 3 - `ot2` BLOB
 * 4 - `odt1` VARCHAR
 * 5 - `odt2` BLOB
 * 
 * Additionally validate support for the types java.time.Offset[Date]Time in ResultSet.getObject().
 * 
 * @param tableName
 * @param expectedRowCount
 * @throws Exception
 */
private void validateTestDataOffsetDTTypes(String tableName, int expectedRowCount) throws Exception {
    Connection testConn = getConnectionWithProps("autoDeserialize=true"); // Offset[Date]Time are supported via object serialization too.
    Statement testStmt = testConn.createStatement();
    this.rs = testStmt.executeQuery("SELECT * FROM " + tableName);

    int rowCount = 0;
    while (rs.next()) {
        String row = "Row " + rs.getInt(1);
        assertEquals(++rowCount, rs.getInt(1));

        assertEquals(row, testOffsetTime, this.rs.getObject(2, OffsetTime.class));
        assertEquals(row, testOffsetTime, this.rs.getObject(3, OffsetTime.class));
        assertEquals(row, testOffsetDateTime, this.rs.getObject(4, OffsetDateTime.class));
        assertEquals(row, testOffsetDateTime, this.rs.getObject(5, OffsetDateTime.class));

        assertEquals(row, rowCount, this.rs.getInt("id"));

        assertEquals(row, testOffsetTime, this.rs.getObject("ot1", OffsetTime.class));
        assertEquals(row, testOffsetTime, this.rs.getObject("ot2", OffsetTime.class));
        assertEquals(row, testOffsetDateTime, this.rs.getObject("odt1", OffsetDateTime.class));
        assertEquals(row, testOffsetDateTime, this.rs.getObject("odt2", OffsetDateTime.class));
    }
    assertEquals(expectedRowCount, rowCount);
    testConn.close();
}
 
Example #3
Source File: XContentElasticsearchExtension.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
public Map<Class<?>, Function<Object, Object>> getDateTransformers() {
    Map<Class<?>, Function<Object, Object>> transformers = new HashMap<>();
    transformers.put(Date.class, d -> DEFAULT_DATE_PRINTER.print(((Date) d).getTime()));
    transformers.put(DateTime.class, d -> DEFAULT_DATE_PRINTER.print((DateTime) d));
    transformers.put(MutableDateTime.class, d -> DEFAULT_DATE_PRINTER.print((MutableDateTime) d));
    transformers.put(ReadableInstant.class, d -> DEFAULT_DATE_PRINTER.print((ReadableInstant) d));
    transformers.put(Long.class, d -> DEFAULT_DATE_PRINTER.print((long) d));
    transformers.put(Calendar.class, d -> DEFAULT_DATE_PRINTER.print(((Calendar) d).getTimeInMillis()));
    transformers.put(GregorianCalendar.class, d -> DEFAULT_DATE_PRINTER.print(((Calendar) d).getTimeInMillis()));
    transformers.put(Instant.class, d -> DEFAULT_DATE_PRINTER.print((Instant) d));
    transformers.put(ZonedDateTime.class, d -> DEFAULT_FORMATTER.format((ZonedDateTime) d));
    transformers.put(OffsetDateTime.class, d -> DEFAULT_FORMATTER.format((OffsetDateTime) d));
    transformers.put(OffsetTime.class, d -> OFFSET_TIME_FORMATTER.format((OffsetTime) d));
    transformers.put(LocalDateTime.class, d -> DEFAULT_FORMATTER.format((LocalDateTime) d));
    transformers.put(java.time.Instant.class,
        d -> DEFAULT_FORMATTER.format(ZonedDateTime.ofInstant((java.time.Instant) d, ZoneOffset.UTC)));
    transformers.put(LocalDate.class, d -> ((LocalDate) d).toString());
    transformers.put(LocalTime.class, d -> LOCAL_TIME_FORMATTER.format((LocalTime) d));
    return transformers;
}
 
Example #4
Source File: TCKOffsetTime.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_isBeforeIsAfterIsEqual1nanos() {
    OffsetTime a = OffsetTime.of(11, 30, 59, 3, OFFSET_PONE);
    OffsetTime b = OffsetTime.of(11, 30, 59, 4, OFFSET_PONE);  // a is before b due to time
    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);
}
 
Example #5
Source File: OffsetTimeSerTest.java    From jackson-modules-java8 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerializationAsTimestamp02() throws Exception
{
    OffsetTime time = OffsetTime.of(9, 22, 57, 0, ZoneOffset.of("-0630"));
    String value = MAPPER.writer()
            .with(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
            .writeValueAsString(time);

    assertNotNull("The value should not be null.", value);
    assertEquals("The value is not correct.", "[9,22,57,\"-06:30\"]", value);
}
 
Example #6
Source File: FreezeTransactionTest.java    From hedera-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
@DisplayName("correct transactions should build")
void correctTxn() {
    final Instant now = Instant.ofEpochSecond(1554158542);
    final TransactionId txnId = TransactionId.withValidStart(new AccountId(2), now);
    final AccountId nodeAcctId = new AccountId(3);

    // start and end times being 0:00 is technically correct
    new FreezeTransaction()
        .setTransactionId(txnId)
        .setNodeAccountId(nodeAcctId)
        .build(null);

    new FreezeTransaction()
        .setTransactionId(txnId)
        .setNodeAccountId(nodeAcctId)
        .setStartTime(OffsetTime.of(0, 0, 0, 0, ZoneOffset.UTC))
        .setEndTime(OffsetTime.of(23, 59, 0, 0, ZoneOffset.UTC))
        .build(null);

    new FreezeTransaction()
        .setTransactionId(txnId)
        .setNodeAccountId(nodeAcctId)
        .setStartTime(OffsetTime.of(0, 0, 0, 0, ZoneOffset.UTC))
        .setEndTime(OffsetTime.of(0, 0, 0, 0, ZoneOffset.UTC))
        .build(null);

    new FreezeTransaction()
        .setTransactionId(txnId)
        .setNodeAccountId(nodeAcctId)
        .setStartTime(OffsetTime.of(23, 59, 0, 0, ZoneOffset.UTC))
        .setEndTime(OffsetTime.of(23, 59, 0, 0, ZoneOffset.UTC))
        .build(null);
}
 
Example #7
Source File: TCKOffsetTime.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void factory_ofInstant_allSecsInDay() {
    for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
        Instant instant = Instant.ofEpochSecond(i, 8);
        OffsetTime test = OffsetTime.ofInstant(instant, ZoneOffset.UTC);
        assertEquals(test.getHour(), (i / (60 * 60)) % 24);
        assertEquals(test.getMinute(), (i / 60) % 60);
        assertEquals(test.getSecond(), i % 60);
        assertEquals(test.getNano(), 8);
    }
}
 
Example #8
Source File: TCKZonedDateTime.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_with_adjuster_OffsetTime_invalidOffsetIgnored2() {
    // OT has invalid offset for ZDT, so only LT is set
    OffsetTime ot = OffsetTime.of(15, 50, 30, 40, OFFSET_0130);
    ZonedDateTime zdt = dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS);  // earlier part of overlap
    ZonedDateTime test = zdt.with(ot);
    assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 15, 50, 30, 40));
    assertEquals(test.getOffset(), OFFSET_0100);  // offset adjusted because of time change
}
 
Example #9
Source File: TCKOffsetTime.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void factory_ofInstant_minYear() {
    OffsetTime test = OffsetTime.ofInstant(Instant.MIN, ZoneOffset.UTC);
    assertEquals(test.getHour(), 0);
    assertEquals(test.getMinute(), 0);
    assertEquals(test.getSecond(), 0);
    assertEquals(test.getNano(), 0);
}
 
Example #10
Source File: TCKZonedDateTime.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
    ZonedDateTime zdt = dateTime(2008, 10, 26, 2, 30, 0, 0, OFFSET_0200, ZONE_PARIS);  // earlier part of overlap
    ZonedDateTime test = zdt.with(ot);
    assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 0, 50, 30, 40));
    assertEquals(test.getOffset(), OFFSET_0200);  // offset not adjusted
}
 
Example #11
Source File: TCKZonedDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap1() {
    // OT has valid offset for resulting time
    OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0100);  // valid offset in overlap
    ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS);  // just before overlap
    ZonedDateTime test = zdt.with(ot);
    assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40));
    assertEquals(test.getOffset(), OFFSET_0100);
}
 
Example #12
Source File: OffsetTimeLib.java    From jdmn with Apache License 2.0 5 votes vote down vote up
public OffsetTime time(String literal) {
    if (StringUtils.isBlank(literal)) {
        return null;
    }

    return this.makeOffsetTime(literal);
}
 
Example #13
Source File: TCKZonedDateTime.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_with_adjuster_OffsetTime_validOffsetIntoOverlap2() {
    // OT has valid offset for resulting time
    OffsetTime ot = OffsetTime.of(2, 30, 30, 40, OFFSET_0200);  // valid offset in overlap
    ZonedDateTime zdt = dateTime(2008, 10, 26, 0, 0, 0, 0, OFFSET_0200, ZONE_PARIS);  // just before overlap
    ZonedDateTime test = zdt.with(ot);
    assertEquals(test.toLocalDateTime(), dateTime(2008, 10, 26, 2, 30, 30, 40));
    assertEquals(test.getOffset(), OFFSET_0200);
}
 
Example #14
Source File: TCKOffsetTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #15
Source File: TCKOffsetTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void factory_ofInstant_beforeEpoch() {
    for (int i =-1; i >= -(24 * 60 * 60); i--) {
        Instant instant = Instant.ofEpochSecond(i, 8);
        OffsetTime test = OffsetTime.ofInstant(instant, ZoneOffset.UTC);
        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);
    }
}
 
Example #16
Source File: JDBCTypeHelperTest.java    From SimpleFlatMapper with MIT License 5 votes vote down vote up
@Test
public void testSqlTypeMappingDefault() {
    testSqlTypes(Timestamp.class, java.util.Date.class, Timestamp.class);

    //IFJAVA8_START
    testSqlTypes(Time.class, OffsetTime.class);
    testSqlTypes(Timestamp.class, OffsetDateTime.class);
    //IFJAVA8_END
}
 
Example #17
Source File: BindParameterTypesTest.java    From pgadba with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void bindTimeWithTimeZoneNoType() throws ExecutionException, InterruptedException, TimeoutException {
  OffsetTime d = OffsetTime.of(3, 10, 1, 220000, ZoneOffset.UTC);

  try (Session session = ds.getSession()) {
    CompletionStage<OffsetTime> idF = session.<OffsetTime>rowOperation("select $1::time with time zone as t")
        .set("$1", d)
        .collect(singleCollector(OffsetTime.class))
        .submit()
        .getCompletionStage();

    assertEquals(d, get10(idF));
  }
}
 
Example #18
Source File: TCKOffsetTime.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example #19
Source File: GraphSONXModuleV3d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new object.
 */
protected GraphSONXModuleV3d0(final boolean normalize) {
    super("graphsonx-3.0");

    /////////////////////// SERIALIZERS ////////////////////////////

    // java.time
    addSerializer(Duration.class, new JavaTimeSerializersV3d0.DurationJacksonSerializer());
    addSerializer(Instant.class, new JavaTimeSerializersV3d0.InstantJacksonSerializer());
    addSerializer(LocalDate.class, new JavaTimeSerializersV3d0.LocalDateJacksonSerializer());
    addSerializer(LocalDateTime.class, new JavaTimeSerializersV3d0.LocalDateTimeJacksonSerializer());
    addSerializer(LocalTime.class, new JavaTimeSerializersV3d0.LocalTimeJacksonSerializer());
    addSerializer(MonthDay.class, new JavaTimeSerializersV3d0.MonthDayJacksonSerializer());
    addSerializer(OffsetDateTime.class, new JavaTimeSerializersV3d0.OffsetDateTimeJacksonSerializer());
    addSerializer(OffsetTime.class, new JavaTimeSerializersV3d0.OffsetTimeJacksonSerializer());
    addSerializer(Period.class, new JavaTimeSerializersV3d0.PeriodJacksonSerializer());
    addSerializer(Year.class, new JavaTimeSerializersV3d0.YearJacksonSerializer());
    addSerializer(YearMonth.class, new JavaTimeSerializersV3d0.YearMonthJacksonSerializer());
    addSerializer(ZonedDateTime.class, new JavaTimeSerializersV3d0.ZonedDateTimeJacksonSerializer());
    addSerializer(ZoneOffset.class, new JavaTimeSerializersV3d0.ZoneOffsetJacksonSerializer());

    /////////////////////// DESERIALIZERS ////////////////////////////

    // java.time
    addDeserializer(Duration.class, new JavaTimeSerializersV3d0.DurationJacksonDeserializer());
    addDeserializer(Instant.class, new JavaTimeSerializersV3d0.InstantJacksonDeserializer());
    addDeserializer(LocalDate.class, new JavaTimeSerializersV3d0.LocalDateJacksonDeserializer());
    addDeserializer(LocalDateTime.class, new JavaTimeSerializersV3d0.LocalDateTimeJacksonDeserializer());
    addDeserializer(LocalTime.class, new JavaTimeSerializersV3d0.LocalTimeJacksonDeserializer());
    addDeserializer(MonthDay.class, new JavaTimeSerializersV3d0.MonthDayJacksonDeserializer());
    addDeserializer(OffsetDateTime.class, new JavaTimeSerializersV3d0.OffsetDateTimeJacksonDeserializer());
    addDeserializer(OffsetTime.class, new JavaTimeSerializersV3d0.OffsetTimeJacksonDeserializer());
    addDeserializer(Period.class, new JavaTimeSerializersV3d0.PeriodJacksonDeserializer());
    addDeserializer(Year.class, new JavaTimeSerializersV3d0.YearJacksonDeserializer());
    addDeserializer(YearMonth.class, new JavaTimeSerializersV3d0.YearMonthJacksonDeserializer());
    addDeserializer(ZonedDateTime.class, new JavaTimeSerializersV3d0.ZonedDateTimeJacksonDeserializer());
    addDeserializer(ZoneOffset.class, new JavaTimeSerializersV3d0.ZoneOffsetJacksonDeserializer());
}
 
Example #20
Source File: TCKOffsetTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void now() {
    ZonedDateTime nowDT = ZonedDateTime.now();

    OffsetTime expected = OffsetTime.now(Clock.systemDefaultZone());
    OffsetTime test = OffsetTime.now();
    long diff = Math.abs(test.toLocalTime().toNanoOfDay() - expected.toLocalTime().toNanoOfDay());
    assertTrue(diff < 100000000);  // less than 0.1 secs
    assertEquals(test.getOffset(), nowDT.getOffset());
}
 
Example #21
Source File: TCKOffsetTime.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void factory_ofInstant_minYear() {
    OffsetTime test = OffsetTime.ofInstant(Instant.MIN, ZoneOffset.UTC);
    assertEquals(test.getHour(), 0);
    assertEquals(test.getMinute(), 0);
    assertEquals(test.getSecond(), 0);
    assertEquals(test.getNano(), 0);
}
 
Example #22
Source File: TCKOffsetTime.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void factory_ofInstant_minYear() {
    OffsetTime test = OffsetTime.ofInstant(Instant.MIN, ZoneOffset.UTC);
    assertEquals(test.getHour(), 0);
    assertEquals(test.getMinute(), 0);
    assertEquals(test.getSecond(), 0);
    assertEquals(test.getNano(), 0);
}
 
Example #23
Source File: OffsetTimeDeserializerIT.java    From bootique with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeserialization02() throws Exception {
    OffsetTime offsetTime = OffsetTime.of(10, 15, 30, 0, ZoneOffset.ofHours(1));

    OffsetTime value = deserialize(OffsetTime.class, "\"10:15:30+01:00\"");

    assertNotNull(value);
    assertEquals(offsetTime, value);
}
 
Example #24
Source File: TCKOffsetTime.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void constructor_nullTime() throws Throwable  {
    Constructor<OffsetTime> con = OffsetTime.class.getDeclaredConstructor(LocalTime.class, ZoneOffset.class);
    con.setAccessible(true);
    try {
        con.newInstance(null, OFFSET_PONE);
    } catch (InvocationTargetException ex) {
        throw ex.getCause();
    }
}
 
Example #25
Source File: TCKOffsetTime.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Test(expectedExceptions=NullPointerException.class)
public void constructor_nullOffset() throws Throwable  {
    Constructor<OffsetTime> con = OffsetTime.class.getDeclaredConstructor(LocalTime.class, ZoneOffset.class);
    con.setAccessible(true);
    try {
        con.newInstance(LocalTime.of(11, 30, 0, 0), null);
    } catch (InvocationTargetException ex) {
        throw ex.getCause();
    }
}
 
Example #26
Source File: TCKOffsetTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #27
Source File: TCKOffsetTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #28
Source File: TCKOffsetTime.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="sampleTimes")
public void test_equals_false_second_differs(int h, int m, int s, int n, ZoneOffset ignored) {
    s = (s == 59 ? 58 : s);
    OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
    OffsetTime b = OffsetTime.of(h, m, s + 1, n, OFFSET_PONE);
    assertEquals(a.equals(b), false);
}
 
Example #29
Source File: TCKOffsetTime.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #30
Source File: TCKOffsetTime.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider="sampleTimes")
public void test_equals_false_hour_differs(int h, int m, int s, int n, ZoneOffset ignored) {
    h = (h == 23 ? 22 : h);
    OffsetTime a = OffsetTime.of(h, m, s, n, OFFSET_PONE);
    OffsetTime b = OffsetTime.of(h + 1, m, s, n, OFFSET_PONE);
    assertEquals(a.equals(b), false);
}