Search in sources :

Example 91 with LocalDateTime

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

the class TCKLocalDateTime method test_plusNanos_fromZero.

@Test(dataProvider = "plusNanos_fromZero")
public void test_plusNanos_fromZero(long nanoseconds, LocalDate date, int hour, int min, int sec, int nanos) {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDateTime t = base.plusNanos(nanoseconds);
    assertEquals(date, t.toLocalDate());
    assertEquals(hour, t.getHour());
    assertEquals(min, t.getMinute());
    assertEquals(sec, t.getSecond());
    assertEquals(nanos, t.getNano());
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 92 with LocalDateTime

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

the class TCKLocalDateTime method test_plus_longTemporalUnit_negativeDays.

@Test
public void test_plus_longTemporalUnit_negativeDays() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plus(-25, ChronoUnit.DAYS);
    assertEquals(t, LocalDateTime.of(2007, 6, 20, 12, 30, 40, 987654321));
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 93 with LocalDateTime

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

the class TCKLocalDateTime method test_minusYears_int_normal.

//-----------------------------------------------------------------------
// minusYears()
//-----------------------------------------------------------------------
@Test
public void test_minusYears_int_normal() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.minusYears(1);
    check(t, 2006, 7, 15, 12, 30, 40, 987654321);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 94 with LocalDateTime

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

the class TCKLocalDateTime method test_plusWeeks_overLeapYears.

@Test
public void test_plusWeeks_overLeapYears() {
    LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.plusYears(-1).plusWeeks(104);
    check(t, 2008, 7, 12, 12, 30, 40, 987654321);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 95 with LocalDateTime

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

the class TCKZonedDateTime method test_minusMinutes_minutes.

@Test
public void test_minusMinutes_minutes() {
    LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
    ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
    ZonedDateTime test = base.minusMinutes(30);
    assertEquals(test, ZonedDateTime.of(ldt.minusMinutes(30), ZONE_0100));
}
Also used : LocalDateTime(java.time.LocalDateTime) ZonedDateTime(java.time.ZonedDateTime) Test(org.testng.annotations.Test)

Aggregations

LocalDateTime (java.time.LocalDateTime)484 Test (org.testng.annotations.Test)282 Test (org.junit.Test)66 ZonedDateTime (java.time.ZonedDateTime)53 LocalDate (java.time.LocalDate)49 LocalTime (java.time.LocalTime)28 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)26 Instant (java.time.Instant)20 DateTimeFormatter (java.time.format.DateTimeFormatter)20 List (java.util.List)18 Date (java.util.Date)17 ZoneId (java.time.ZoneId)16 AbstractTCKTest (tck.java.time.AbstractTCKTest)14 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)12 OffsetDateTime (java.time.OffsetDateTime)11 ZoneOffset (java.time.ZoneOffset)11 DateTimeParseException (java.time.format.DateTimeParseException)11 ZoneRules (java.time.zone.ZoneRules)10 IOException (java.io.IOException)9