Search in sources :

Example 61 with OffsetDateTime

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));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Example 62 with OffsetDateTime

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);
    }
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Instant(java.time.Instant) Clock(java.time.Clock) Test(org.testng.annotations.Test)

Example 63 with OffsetDateTime

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);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Example 64 with OffsetDateTime

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);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Example 65 with OffsetDateTime

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);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Aggregations

OffsetDateTime (java.time.OffsetDateTime)199 Test (org.testng.annotations.Test)139 Test (org.junit.Test)26 Instant (java.time.Instant)22 ZonedDateTime (java.time.ZonedDateTime)18 LocalDateTime (java.time.LocalDateTime)13 LocalDate (java.time.LocalDate)12 LocalTime (java.time.LocalTime)11 OffsetTime (java.time.OffsetTime)7 Map (java.util.Map)7 Timestamp (java.sql.Timestamp)6 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)6 ZoneOffset (java.time.ZoneOffset)5 Date (java.sql.Date)4 Clock (java.time.Clock)4 Duration (java.time.Duration)4 DateTimeFormatter (java.time.format.DateTimeFormatter)4 Collections.emptyMap (java.util.Collections.emptyMap)4 UUID (java.util.UUID)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4