Search in sources :

Example 46 with LocalTime

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

the class TestLocalDateTime method test_getTime.

//-----------------------------------------------------------------------
// toLocalTime()
//-----------------------------------------------------------------------
@Test(dataProvider = "sampleTimes")
public void test_getTime(int h, int m, int s, int ns) {
    LocalTime t = LocalTime.of(h, m, s, ns);
    LocalDateTime dt = LocalDateTime.of(LocalDate.of(2011, 7, 30), t);
    assertSame(dt.toLocalTime(), t);
}
Also used : LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 47 with LocalTime

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

the class TCKLocalTime method test_minusSeconds_toMidnight_equal.

@Test
public void test_minusSeconds_toMidnight_equal() {
    LocalTime t = LocalTime.of(0, 0, 1).minusSeconds(1);
    assertEquals(t, LocalTime.MIDNIGHT);
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 48 with LocalTime

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

the class TCKLocalTime method test_with_longTemporalField_notChronoField.

// If the field is not a {@code ChronoField}, then the result of this method
// is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)}
// passing {@code this} as the argument.
@Test
public void test_with_longTemporalField_notChronoField() {
    final LocalTime result = LocalTime.of(12, 30);
    final LocalTime base = LocalTime.of(15, 45);
    TemporalField field = new TemporalField() {

        public ValueRange rangeRefinedBy(TemporalAccessor temporal) {
            throw new UnsupportedOperationException();
        }

        public ValueRange range() {
            return null;
        }

        public boolean isTimeBased() {
            throw new UnsupportedOperationException();
        }

        public boolean isSupportedBy(TemporalAccessor temporal) {
            throw new UnsupportedOperationException();
        }

        public boolean isDateBased() {
            throw new UnsupportedOperationException();
        }

        public TemporalUnit getRangeUnit() {
            throw new UnsupportedOperationException();
        }

        public long getFrom(TemporalAccessor temporal) {
            throw new UnsupportedOperationException();
        }

        public TemporalUnit getBaseUnit() {
            throw new UnsupportedOperationException();
        }

        public <R extends Temporal> R adjustInto(R temporal, long newValue) {
            assertEquals(temporal, base);
            assertEquals(newValue, 12L);
            @SuppressWarnings("unchecked") R r = (R) result;
            return r;
        }
    };
    LocalTime test = base.with(field, 12L);
    assertSame(test, result);
}
Also used : MINUTE_OF_HOUR(java.time.temporal.ChronoField.MINUTE_OF_HOUR) FOREVER(java.time.temporal.ChronoUnit.FOREVER) TemporalField(java.time.temporal.TemporalField) TemporalAccessor(java.time.temporal.TemporalAccessor) LocalTime(java.time.LocalTime) Temporal(java.time.temporal.Temporal) Test(org.testng.annotations.Test)

Example 49 with LocalTime

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

the class TCKLocalTime method test_plusSeconds_toMidday_equal.

@Test
public void test_plusSeconds_toMidday_equal() {
    LocalTime t = LocalTime.of(11, 59, 59).plusSeconds(1);
    assertEquals(t, LocalTime.NOON);
}
Also used : LocalTime(java.time.LocalTime) Test(org.testng.annotations.Test)

Example 50 with LocalTime

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

the class TCKLocalTime method test_minus_longTemporalUnit_zero.

@Test
public void test_minus_longTemporalUnit_zero() {
    LocalTime t = TEST_12_30_40_987654321.minus(0, ChronoUnit.MINUTES);
    assertEquals(t, TEST_12_30_40_987654321);
}
Also used : LocalTime(java.time.LocalTime) 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