use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_withMinute_normal.
//-----------------------------------------------------------------------
// withMinute()
//-----------------------------------------------------------------------
@Test
public void test_withMinute_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.withMinute(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 15, 59), OFFSET_PONE));
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_equals_true.
//-----------------------------------------------------------------------
// equals() / hashCode()
//-----------------------------------------------------------------------
@Test(dataProvider = "sampleTimes")
public void test_equals_true(int y, int o, int d, int h, int m, int s, int n, ZoneOffset ignored) {
OffsetDateTime a = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE);
OffsetDateTime b = OffsetDateTime.of(y, o, d, h, m, s, n, OFFSET_PONE);
assertEquals(a.equals(b), true);
assertEquals(a.hashCode() == b.hashCode(), true);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_withHour_normal.
//-----------------------------------------------------------------------
// withHour()
//-----------------------------------------------------------------------
@Test
public void test_withHour_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.withHour(15);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(15, 30, 59), OFFSET_PONE));
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method now_Clock_allSecsInDay_offset.
@Test
public void now_Clock_allSecsInDay_offset() {
for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L);
Clock clock = Clock.fixed(instant.minusSeconds(OFFSET_PONE.getTotalSeconds()), OFFSET_PONE);
OffsetDateTime test = OffsetDateTime.now(clock);
assertEquals(test.getYear(), 1970);
assertEquals(test.getMonth(), Month.JANUARY);
assertEquals(test.getDayOfMonth(), (i < 24 * 60 * 60) ? 1 : 2);
assertEquals(test.getHour(), (i / (60 * 60)) % 24);
assertEquals(test.getMinute(), (i / 60) % 60);
assertEquals(test.getSecond(), i % 60);
assertEquals(test.getNano(), 123456789);
assertEquals(test.getOffset(), OFFSET_PONE);
}
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method now_Clock_allSecsInDay_beforeEpoch.
@Test
public void now_Clock_allSecsInDay_beforeEpoch() {
LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L);
for (int i = -1; i >= -(24 * 60 * 60); i--) {
Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L);
Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
OffsetDateTime test = OffsetDateTime.now(clock);
assertEquals(test.getYear(), 1969);
assertEquals(test.getMonth(), Month.DECEMBER);
assertEquals(test.getDayOfMonth(), 31);
expected = expected.minusSeconds(1);
assertEquals(test.toLocalTime(), expected);
assertEquals(test.getOffset(), ZoneOffset.UTC);
}
}
Aggregations