use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_get_TemporalField.
//-----------------------------------------------------------------------
// get(TemporalField)
//-----------------------------------------------------------------------
@Test
public void test_get_TemporalField() {
OffsetDateTime test = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(12, 30, 40, 987654321), OFFSET_PONE);
assertEquals(test.get(ChronoField.YEAR), 2008);
assertEquals(test.get(ChronoField.MONTH_OF_YEAR), 6);
assertEquals(test.get(ChronoField.DAY_OF_MONTH), 30);
assertEquals(test.get(ChronoField.DAY_OF_WEEK), 1);
assertEquals(test.get(ChronoField.DAY_OF_YEAR), 182);
assertEquals(test.get(ChronoField.HOUR_OF_DAY), 12);
assertEquals(test.get(ChronoField.MINUTE_OF_HOUR), 30);
assertEquals(test.get(ChronoField.SECOND_OF_MINUTE), 40);
assertEquals(test.get(ChronoField.NANO_OF_SECOND), 987654321);
assertEquals(test.get(ChronoField.HOUR_OF_AMPM), 0);
assertEquals(test.get(ChronoField.AMPM_OF_DAY), 1);
assertEquals(test.get(ChronoField.OFFSET_SECONDS), 3600);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_compareTo_offsetNanos.
@Test
public void test_compareTo_offsetNanos() {
OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 40, 6, OFFSET_PTWO);
// a is before b due to offset
OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 40, 5, 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(a.toInstant().compareTo(b.toInstant()) < 0, true);
assertEquals(OffsetDateTime.timeLineOrder().compare(a, b) < 0, true);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_equals_false_minute_differs.
@Test(dataProvider = "sampleTimes")
public void test_equals_false_minute_differs(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) {
m = (m == 59 ? 58 : m);
OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE);
OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m + 1, s, n, OFFSET_PONE);
assertEquals(a.equals(b), false);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_minusNanos.
//-----------------------------------------------------------------------
// minusNanos()
//-----------------------------------------------------------------------
@Test
public void test_minusNanos() {
OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
OffsetDateTime test = base.minusNanos(1);
assertEquals(test, OffsetDateTime.of(2008, 6, 30, 11, 30, 58, 999999999, OFFSET_PONE));
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_compareTo_timeSecs.
@Test
public void test_compareTo_timeSecs() {
OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 29, 2, 0, OFFSET_PONE);
// a is before b due to time
OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 29, 3, 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(a.toInstant().compareTo(b.toInstant()) < 0, true);
assertEquals(OffsetDateTime.timeLineOrder().compare(a, b) < 0, true);
}
Aggregations