Search in sources :

Example 6 with LocalTime

use of java.time.LocalTime in project querydsl by querydsl.

the class JSR310LocalTimeTypeTest method jodaSet.

@Test
public void jodaSet() throws SQLException {
    LocalTime value = LocalTime.now();
    Time time = new Time(value.get(ChronoField.MILLI_OF_DAY));
    PreparedStatement stmt = EasyMock.createNiceMock(PreparedStatement.class);
    stmt.setTime(1, time, UTC);
    EasyMock.replay(stmt);
    new LocalTimeType().setValue(stmt, 1, toJoda(value));
    EasyMock.verify(stmt);
}
Also used : LocalTime(java.time.LocalTime) Time(java.sql.Time) LocalTime(java.time.LocalTime) PreparedStatement(java.sql.PreparedStatement) Test(org.junit.Test)

Example 7 with LocalTime

use of java.time.LocalTime in project requery by requery.

the class TimeConversionsTest method testInsertReadLocalTime.

@Test
public void testInsertReadLocalTime() {
    Event event = new Event();
    UUID id = UUID.randomUUID();
    LocalTime localTimeNow = LocalTime.now();
    event.setId(id);
    event.setLocalTime(localTimeNow);
    data.insert(event);
    event = data.findByKey(Event.class, id);
    Assert.assertEquals(localTimeNow.withNano(0), event.getLocalTime());
}
Also used : LocalTime(java.time.LocalTime) Event(io.requery.test.model2.Event) UUID(java.util.UUID) Test(org.junit.Test)

Example 8 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 9 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 10 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)188 Test (org.testng.annotations.Test)164 LocalDate (java.time.LocalDate)21 LocalDateTime (java.time.LocalDateTime)20 Instant (java.time.Instant)11 Clock (java.time.Clock)8 TemporalAmount (java.time.temporal.TemporalAmount)8 Test (org.junit.Test)8 OffsetDateTime (java.time.OffsetDateTime)7 Time (java.sql.Time)6 OffsetTime (java.time.OffsetTime)5 DateTimeFormatter (java.time.format.DateTimeFormatter)5 ZonedDateTime (java.time.ZonedDateTime)4 ZoneId (java.time.ZoneId)3 TemporalAccessor (java.time.temporal.TemporalAccessor)3 BaseTest (util.BaseTest)3 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 ZoneOffset (java.time.ZoneOffset)2 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)2