Search in sources :

Example 26 with LocalDateTime

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

the class TCKLocalDateTime method test_minusDays_symmetry.

@Test(dataProvider = "sampleMinusDaysSymmetry")
public void test_minusDays_symmetry(LocalDateTime reference) {
    for (int days = 0; days < 365 * 8; days++) {
        LocalDateTime t = reference.minusDays(days).minusDays(-days);
        assertEquals(t, reference);
        t = reference.minusDays(-days).minusDays(days);
        assertEquals(t, reference);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 27 with LocalDateTime

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

the class TCKLocalDateTime method test_get_dates.

//-----------------------------------------------------------------------
// get*()
//-----------------------------------------------------------------------
@Test(dataProvider = "sampleDates")
public void test_get_dates(int y, int m, int d) {
    LocalDateTime a = LocalDateTime.of(y, m, d, 12, 30);
    assertEquals(a.getYear(), y);
    assertEquals(a.getMonth(), Month.of(m));
    assertEquals(a.getDayOfMonth(), d);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 28 with LocalDateTime

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

the class TCKLocalDateTime method test_comparisons_LocalDateTime.

void test_comparisons_LocalDateTime(LocalDate[] localDates, LocalTime... localTimes) {
    LocalDateTime[] localDateTimes = new LocalDateTime[localDates.length * localTimes.length];
    int i = 0;
    for (LocalDate localDate : localDates) {
        for (LocalTime localTime : localTimes) {
            localDateTimes[i++] = LocalDateTime.of(localDate, localTime);
        }
    }
    doTest_comparisons_LocalDateTime(localDateTimes);
}
Also used : LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) LocalDate(java.time.LocalDate)

Example 29 with LocalDateTime

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

the class TCKLocalDateTime method test_getDOY.

@Test(dataProvider = "sampleDates")
public void test_getDOY(int y, int m, int d) {
    LocalDateTime a = LocalDateTime.of(y, m, d, 12, 30);
    int total = 0;
    for (int i = 1; i < m; i++) {
        total += Month.of(i).length(isIsoLeap(y));
    }
    int doy = total + d;
    assertEquals(a.getDayOfYear(), doy);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Example 30 with LocalDateTime

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

the class TCKLocalDateTime method test_plusYears_int_adjustDay.

@Test
public void test_plusYears_int_adjustDay() {
    LocalDateTime t = createDateMidnight(2008, 2, 29).plusYears(1);
    check(t, 2009, 2, 28, 0, 0, 0, 0);
}
Also used : LocalDateTime(java.time.LocalDateTime) Test(org.testng.annotations.Test)

Aggregations

LocalDateTime (java.time.LocalDateTime)399 Test (org.testng.annotations.Test)280 ZonedDateTime (java.time.ZonedDateTime)45 Test (org.junit.Test)40 LocalDate (java.time.LocalDate)33 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)26 LocalTime (java.time.LocalTime)20 Instant (java.time.Instant)19 DateTimeFormatter (java.time.format.DateTimeFormatter)16 ZoneId (java.time.ZoneId)15 AbstractTCKTest (tck.java.time.AbstractTCKTest)14 OffsetDateTime (java.time.OffsetDateTime)10 ZoneRules (java.time.zone.ZoneRules)10 ZoneOffset (java.time.ZoneOffset)9 Date (java.util.Date)8 List (java.util.List)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 Timestamp (java.sql.Timestamp)6 ChronoLocalDateTime (java.time.chrono.ChronoLocalDateTime)6