Search in sources :

Example 16 with OffsetDateTime

use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.

the class TCKOffsetDateTime method test_with_adjustment_Month.

@Test
public void test_with_adjustment_Month() {
    OffsetDateTime test = TEST_2008_6_30_11_30_59_000000500.with(DECEMBER);
    assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 12, 30), LocalTime.of(11, 30, 59, 500), OFFSET_PONE));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Example 17 with OffsetDateTime

use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.

the class TCKOffsetDateTime method test_compareTo_offset.

@Test
public void test_compareTo_offset() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 0, OFFSET_PTWO);
    // a is before b due to offset
    OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 0, 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);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Example 18 with OffsetDateTime

use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.

the class TCKOffsetDateTime method test_compareTo_max.

@Test
public void test_compareTo_max() {
    OffsetDateTime a = OffsetDateTime.of(Year.MAX_VALUE, 12, 31, 23, 59, 0, 0, OFFSET_MONE);
    // a is before b due to offset
    OffsetDateTime b = OffsetDateTime.of(Year.MAX_VALUE, 12, 31, 23, 59, 0, 0, OFFSET_MTWO);
    assertEquals(a.compareTo(b) < 0, true);
    assertEquals(b.compareTo(a) > 0, true);
    assertEquals(a.compareTo(a) == 0, true);
    assertEquals(b.compareTo(b) == 0, true);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Example 19 with OffsetDateTime

use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.

the class TCKOffsetDateTime method test_withNanoOfSecond_normal.

//-----------------------------------------------------------------------
// withNano()
//-----------------------------------------------------------------------
@Test
public void test_withNanoOfSecond_normal() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 1), OFFSET_PONE);
    OffsetDateTime test = base.withNano(15);
    assertEquals(test, OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59, 15), OFFSET_PONE));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Example 20 with OffsetDateTime

use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.

the class TCKOffsetDateTime method test_plus_Period.

//-----------------------------------------------------------------------
// plus(Period)
//-----------------------------------------------------------------------
@Test
public void test_plus_Period() {
    MockSimplePeriod period = MockSimplePeriod.of(7, ChronoUnit.MONTHS);
    OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(period);
    assertEquals(t, OffsetDateTime.of(2009, 1, 30, 11, 30, 59, 500, OFFSET_PONE));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) MockSimplePeriod(test.java.time.MockSimplePeriod) Test(org.testng.annotations.Test)

Aggregations

OffsetDateTime (java.time.OffsetDateTime)191 Test (org.testng.annotations.Test)139 Instant (java.time.Instant)22 Test (org.junit.Test)20 ZonedDateTime (java.time.ZonedDateTime)17 LocalDateTime (java.time.LocalDateTime)12 LocalDate (java.time.LocalDate)11 LocalTime (java.time.LocalTime)10 Timestamp (java.sql.Timestamp)6 OffsetTime (java.time.OffsetTime)6 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)6 Map (java.util.Map)6 Date (java.sql.Date)4 Clock (java.time.Clock)4 ZoneOffset (java.time.ZoneOffset)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 MapUtil.stringMap (org.neo4j.helpers.collection.MapUtil.stringMap)4