use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_withMonth_normal.
//-----------------------------------------------------------------------
// withMonth()
//-----------------------------------------------------------------------
@Test
public void test_withMonth_normal() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
OffsetDateTime test = base.withMonth(1);
assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 1, 30), LocalTime.of(11, 30, 59), OFFSET_PONE));
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method now_Clock_allSecsInDay_utc.
//-----------------------------------------------------------------------
// now(Clock)
//-----------------------------------------------------------------------
@Test
public void now_Clock_allSecsInDay_utc() {
for (int i = 0; i < (2 * 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(), 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(), ZoneOffset.UTC);
}
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_withOffsetSameInstant_null.
@Test(expectedExceptions = NullPointerException.class)
public void test_withOffsetSameInstant_null() {
OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
base.withOffsetSameInstant(null);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_compareTo_null.
@Test(expectedExceptions = NullPointerException.class)
public void test_compareTo_null() {
OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
a.compareTo(null);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKOffsetDateTime method test_atZone_dstOverlapWinter.
@Test
public void test_atZone_dstOverlapWinter() {
OffsetDateTime t = OffsetDateTime.of(2007, 10, 28, 2, 30, 0, 0, OFFSET_PONE);
assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).toLocalDateTime(), t.toLocalDateTime());
assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).getOffset(), OFFSET_PONE);
assertEquals(t.atZoneSimilarLocal(ZONE_PARIS).getZone(), ZONE_PARIS);
}
Aggregations