Search in sources :

Example 46 with OffsetDateTime

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

the class TestOffsetDateTime method test_plusMinutes_zero.

@Test
public void test_plusMinutes_zero() {
    OffsetDateTime base = OffsetDateTime.of(LocalDate.of(2008, 6, 30), LocalTime.of(11, 30, 59), OFFSET_PONE);
    OffsetDateTime test = base.plusMinutes(0);
    assertSame(test, base);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Test(org.testng.annotations.Test)

Example 47 with OffsetDateTime

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

the class TCKOffsetTime method test_until_convertedType.

@Test
public void test_until_convertedType() {
    OffsetTime offsetTime = OffsetTime.of(1, 1, 1, 0, OFFSET_PONE);
    OffsetDateTime offsetDateTime = offsetTime.plusSeconds(3).atDate(LocalDate.of(1980, 2, 10));
    assertEquals(offsetTime.until(offsetDateTime, SECONDS), 3);
}
Also used : OffsetDateTime(java.time.OffsetDateTime) OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Example 48 with OffsetDateTime

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

the class TCKOffsetDateTime method test_compareTo_both.

@Test
public void test_compareTo_both() {
    OffsetDateTime a = OffsetDateTime.of(2008, 6, 30, 11, 50, 0, 0, OFFSET_PTWO);
    // a is before b on instant scale
    OffsetDateTime b = OffsetDateTime.of(2008, 6, 30, 11, 20, 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 49 with OffsetDateTime

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

the class TCKOffsetDateTime method test_withDayOfMonth_normal.

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

Example 50 with OffsetDateTime

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

the class TCKOffsetDateTime method test_minusMonths.

//-----------------------------------------------------------------------
// minusMonths()
//-----------------------------------------------------------------------
@Test
public void test_minusMonths() {
    OffsetDateTime base = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 0, OFFSET_PONE);
    OffsetDateTime test = base.minusMonths(1);
    assertEquals(test, OffsetDateTime.of(2008, 5, 30, 11, 30, 59, 0, OFFSET_PONE));
}
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