Search in sources :

Example 51 with LocalDateTime

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

the class TestChronoLocalDate method test_date_checkGenerics_chronoLocalDateTime1.

public void test_date_checkGenerics_chronoLocalDateTime1() {
    LocalDateTime now = LocalDateTime.now();
    Chronology chrono = ThaiBuddhistChronology.INSTANCE;
    ChronoLocalDateTime<?> ldt = chrono.localDateTime(now);
    ldt = processCLDT(ldt);
}
Also used : ChronoLocalDateTime(java.time.chrono.ChronoLocalDateTime) LocalDateTime(java.time.LocalDateTime) Chronology(java.time.chrono.Chronology) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology)

Example 52 with LocalDateTime

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

the class TestUmmAlQuraChronology method test_LocalDateTime_adjustToHijrahDate.

// Test to get the local date time by applying the MIN adjustment with hijrah date
@Test(dataProvider = "samples")
public void test_LocalDateTime_adjustToHijrahDate(ChronoLocalDate hijrahDate, LocalDate localDate) {
    LocalDateTime test = LocalDateTime.MIN.with(hijrahDate);
    assertEquals(test, LocalDateTime.of(localDate, LocalTime.MIDNIGHT));
}
Also used : LocalDateTime(java.time.LocalDateTime) ChronoLocalDateTime(java.time.chrono.ChronoLocalDateTime) Test(org.testng.annotations.Test)

Example 53 with LocalDateTime

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

the class TestChronoLocalDate method test_date_checkGenerics_chronoLocalDateTime2.

public void test_date_checkGenerics_chronoLocalDateTime2() {
    LocalDateTime now = LocalDateTime.now();
    Chronology chrono = ThaiBuddhistChronology.INSTANCE;
    ChronoLocalDateTime<? extends ChronoLocalDate> ldt = chrono.localDateTime(now);
    ldt = processCLDT(ldt);
}
Also used : ChronoLocalDateTime(java.time.chrono.ChronoLocalDateTime) LocalDateTime(java.time.LocalDateTime) Chronology(java.time.chrono.Chronology) ThaiBuddhistChronology(java.time.chrono.ThaiBuddhistChronology)

Example 54 with LocalDateTime

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

the class TCKLocalTime method test_until_convertedType.

@Test
public void test_until_convertedType() {
    LocalTime start = LocalTime.of(11, 30);
    LocalDateTime end = start.plusSeconds(2).atDate(LocalDate.of(2010, 6, 30));
    assertEquals(start.until(end, SECONDS), 2);
}
Also used : LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 55 with LocalDateTime

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

the class TCKZonedDateTime method test_get.

@Test(dataProvider = "sampleTimes")
public void test_get(int y, int o, int d, int h, int m, int s, int n, ZoneId zone) {
    LocalDate localDate = LocalDate.of(y, o, d);
    LocalTime localTime = LocalTime.of(h, m, s, n);
    LocalDateTime localDateTime = LocalDateTime.of(localDate, localTime);
    ZoneOffset offset = zone.getRules().getOffset(localDateTime);
    ZonedDateTime a = ZonedDateTime.of(localDateTime, zone);
    assertEquals(a.getYear(), localDate.getYear());
    assertEquals(a.getMonth(), localDate.getMonth());
    assertEquals(a.getDayOfMonth(), localDate.getDayOfMonth());
    assertEquals(a.getDayOfYear(), localDate.getDayOfYear());
    assertEquals(a.getDayOfWeek(), localDate.getDayOfWeek());
    assertEquals(a.getHour(), localTime.getHour());
    assertEquals(a.getMinute(), localTime.getMinute());
    assertEquals(a.getSecond(), localTime.getSecond());
    assertEquals(a.getNano(), localTime.getNano());
    assertEquals(a.toLocalDate(), localDate);
    assertEquals(a.toLocalTime(), localTime);
    assertEquals(a.toLocalDateTime(), localDateTime);
    if (zone instanceof ZoneOffset) {
        assertEquals(a.toString(), localDateTime.toString() + offset.toString());
    } else {
        assertEquals(a.toString(), localDateTime.toString() + offset.toString() + "[" + zone.toString() + "]");
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) ZonedDateTime(java.time.ZonedDateTime) LocalDate(java.time.LocalDate) ZoneOffset(java.time.ZoneOffset) 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