use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_equals_false_hour_differs.
@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);
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method factory_ofInstant_allSecsInDay.
@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);
}
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method now.
//-----------------------------------------------------------------------
// now()
//-----------------------------------------------------------------------
@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());
// less than 0.1 secs
assertTrue(diff < 100000000);
assertEquals(test.getOffset(), nowDT.getOffset());
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_compareTo_hourDifference.
@Test
public void test_compareTo_hourDifference() {
OffsetTime a = OffsetTime.of(10, 0, 0, 0, OFFSET_PONE);
// a is before b despite being same time-line time
OffsetTime b = OffsetTime.of(11, 0, 0, 0, OFFSET_PTWO);
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);
}
use of java.time.OffsetTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method test_withSecond_normal.
//-----------------------------------------------------------------------
// withSecond()
//-----------------------------------------------------------------------
@Test
public void test_withSecond_normal() {
OffsetTime base = OffsetTime.of(11, 30, 59, 0, OFFSET_PONE);
OffsetTime test = base.withSecond(15);
assertEquals(test, OffsetTime.of(11, 30, 15, 0, OFFSET_PONE));
}
Aggregations