Search in sources :

Example 86 with LocalTime

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

the class TestLocalTime method factory_time_4ints_singletons.

@Test
public void factory_time_4ints_singletons() {
    for (int i = 0; i < 24; i++) {
        LocalTime test1 = LocalTime.of(i, 0, 0, 0);
        LocalTime test2 = LocalTime.of(i, 0, 0, 0);
        assertSame(test1, test2);
    }
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 87 with LocalTime

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

the class TestLocalTime method factory_ofSecondOfDay_singletons.

@Test
public void factory_ofSecondOfDay_singletons() {
    for (int i = 0; i < 24; i++) {
        LocalTime test1 = LocalTime.ofSecondOfDay(i * 60L * 60L);
        LocalTime test2 = LocalTime.of(i, 0);
        assertSame(test1, test2);
    }
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 88 with LocalTime

use of java.time.LocalTime 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 89 with LocalTime

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

the class TCKLocalDateTime method test_minusMinutes_fromZero.

@Test
public void test_minusMinutes_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().minusDays(1);
    LocalTime t = LocalTime.of(22, 49);
    for (int i = 70; i > -70; i--) {
        LocalDateTime dt = base.minusMinutes(i);
        t = t.plusMinutes(1);
        if (t.equals(LocalTime.MIDNIGHT)) {
            d = d.plusDays(1);
        }
        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 90 with LocalTime

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

the class TCKOffsetTime method factory_LocalTimeZoneOffset.

//-----------------------------------------------------------------------
@Test
public void factory_LocalTimeZoneOffset() {
    LocalTime localTime = LocalTime.of(11, 30, 10, 500);
    OffsetTime test = OffsetTime.of(localTime, OFFSET_PONE);
    check(test, 11, 30, 10, 500, OFFSET_PONE);
}
Also used : LocalTime(java.time.LocalTime) OffsetTime(java.time.OffsetTime) Test(org.testng.annotations.Test)

Aggregations

LocalTime (java.time.LocalTime)676 Test (org.junit.Test)262 Test (org.testng.annotations.Test)173 LocalDate (java.time.LocalDate)156 LocalDateTime (java.time.LocalDateTime)130 ZonedDateTime (java.time.ZonedDateTime)36 Date (java.util.Date)32 Instant (java.time.Instant)30 OffsetDateTime (java.time.OffsetDateTime)30 DateTimeFormatter (java.time.format.DateTimeFormatter)27 Test (org.junit.jupiter.api.Test)27 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)23 ZoneOffset (java.time.ZoneOffset)23 ZoneId (java.time.ZoneId)22 ArrayList (java.util.ArrayList)19 BigDecimal (java.math.BigDecimal)18 TemporalAccessor (java.time.temporal.TemporalAccessor)18 TemporalAmount (java.time.temporal.TemporalAmount)18 Time (java.sql.Time)17 Clock (java.time.Clock)17