Search in sources :

Example 96 with OffsetDateTime

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

the class TCKOffsetDateTime method test_compareTo_timeNanos.

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

Example 97 with OffsetDateTime

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

the class TCKOffsetDateTime method test_isEqual_null.

@Test(expectedExceptions = NullPointerException.class)
public void test_isEqual_null() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    a.isEqual(null);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Example 98 with OffsetDateTime

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

the class TCKOffsetDateTime method test_compareTo_hourDifference.

@Test
public void test_compareTo_hourDifference() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 10, 0, 0, 0, OFFSET_PONE);
    // a is before b despite being same time-line time
    OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 0, 0, 0, OFFSET_PTWO);
    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);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Example 99 with OffsetDateTime

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

the class TCKOffsetDateTime method test_compareTo_timeMins.

//-----------------------------------------------------------------------
// compareTo()
//-----------------------------------------------------------------------
@Test
public void test_compareTo_timeMins() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 29, 3, 0, OFFSET_PONE);
    // a is before b due to time
    OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 30, 2, 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 100 with OffsetDateTime

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

the class TCKOffsetDateTime method test_plusHours.

//-----------------------------------------------------------------------
// plusHours()
//-----------------------------------------------------------------------
@Test
public void test_plusHours() {
    OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    OffsetDateTime test = base.plusHours(13);
    assertEquals(test, OffsetDateTime.of(2008, 7, 1, 0, 30, 59, 0, OFFSET_PONE));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) 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