Java Code Examples for java.time.LocalTime#plusHours()

The following examples show how to use java.time.LocalTime#plusHours() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKLocalDateTime.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusHours_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().minusDays(3);
    LocalTime t = LocalTime.of(21, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.plusHours(i);
        t = t.plusHours(1);

        if (t.getHour() == 0) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
Example 2
Source File: TCKLocalDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0));
    LocalDate d = base.toLocalDate().minusDays(3);
    LocalTime t = LocalTime.of(22, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.plusHours(i);

        t = t.plusHours(1);

        if (t.getHour() == 0) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
Example 3
Source File: TCKLocalDateTime.java    From j2objc with Apache License 2.0 6 votes vote down vote up
@Test
public void test_plusHours_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().minusDays(3);
    LocalTime t = LocalTime.of(21, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.plusHours(i);
        t = t.plusHours(1);

        if (t.getHour() == 0) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
Example 4
Source File: TCKLocalDateTime.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusHours_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().minusDays(3);
    LocalTime t = LocalTime.of(21, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.plusHours(i);
        t = t.plusHours(1);

        if (t.getHour() == 0) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
Example 5
Source File: TCKLocalDateTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0));
    LocalDate d = base.toLocalDate().minusDays(3);
    LocalTime t = LocalTime.of(22, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.plusHours(i);

        t = t.plusHours(1);

        if (t.getHour() == 0) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
Example 6
Source File: TCKLocalDateTime.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0));
    LocalDate d = base.toLocalDate().minusDays(3);
    LocalTime t = LocalTime.of(22, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.plusHours(i);

        t = t.plusHours(1);

        if (t.getHour() == 0) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
Example 7
Source File: TCKLocalDateTime.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusHours_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().minusDays(3);
    LocalTime t = LocalTime.of(21, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.plusHours(i);
        t = t.plusHours(1);

        if (t.getHour() == 0) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
Example 8
Source File: TCKLocalDateTime.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0));
    LocalDate d = base.toLocalDate().minusDays(3);
    LocalTime t = LocalTime.of(22, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.plusHours(i);

        t = t.plusHours(1);

        if (t.getHour() == 0) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
Example 9
Source File: TCKLocalDateTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusHours_fromZero() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT);
    LocalDate d = base.toLocalDate().minusDays(3);
    LocalTime t = LocalTime.of(21, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.plusHours(i);
        t = t.plusHours(1);

        if (t.getHour() == 0) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
Example 10
Source File: TCKLocalDateTime.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalDateTime base = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.of(1, 0));
    LocalDate d = base.toLocalDate().minusDays(3);
    LocalTime t = LocalTime.of(22, 0);

    for (int i = -50; i < 50; i++) {
        LocalDateTime dt = base.plusHours(i);

        t = t.plusHours(1);

        if (t.getHour() == 0) {
            d = d.plusDays(1);
        }

        assertEquals(dt.toLocalDate(), d);
        assertEquals(dt.toLocalTime(), t);
    }
}
 
Example 11
Source File: TCKLocalTime.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_plusHours_fromZero() {
    LocalTime base = LocalTime.MIDNIGHT;
    for (int i = -50; i < 50; i++) {
        LocalTime t = base.plusHours(i);
        assertEquals(t.getHour(), (i + 72) % 24);
    }
}
 
Example 12
Source File: TCKLocalTime.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalTime base = LocalTime.of(1, 0);
    for (int i = -50; i < 50; i++) {
        LocalTime t = base.plusHours(i);
        assertEquals(t.getHour(), (1 + i + 72) % 24);
    }
}
 
Example 13
Source File: TCKLocalTime.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalTime base = LocalTime.of(1, 0);
    for (int i = -50; i < 50; i++) {
        LocalTime t = base.plusHours(i);
        assertEquals(t.getHour(), (1 + i + 72) % 24);
    }
}
 
Example 14
Source File: TCKLocalTime.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalTime base = LocalTime.of(1, 0);
    for (int i = -50; i < 50; i++) {
        LocalTime t = base.plusHours(i);
        assertEquals(t.getHour(), (1 + i + 72) % 24);
    }
}
 
Example 15
Source File: TCKLocalTime.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalTime base = LocalTime.of(1, 0);
    for (int i = -50; i < 50; i++) {
        LocalTime t = base.plusHours(i);
        assertEquals(t.getHour(), (1 + i + 72) % 24);
    }
}
 
Example 16
Source File: TCKLocalTime.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_plusHours_fromZero() {
    LocalTime base = LocalTime.MIDNIGHT;
    for (int i = -50; i < 50; i++) {
        LocalTime t = base.plusHours(i);
        assertEquals(t.getHour(), (i + 72) % 24);
    }
}
 
Example 17
Source File: TCKLocalTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalTime base = LocalTime.of(1, 0);
    for (int i = -50; i < 50; i++) {
        LocalTime t = base.plusHours(i);
        assertEquals(t.getHour(), (1 + i + 72) % 24);
    }
}
 
Example 18
Source File: EntityManagerTest.java    From catatumbo with Apache License 2.0 5 votes vote down vote up
@Test
public void testUpdateLocalTimeField() {
  LocalTimeField entity = new LocalTimeField();
  LocalTime now = LocalTime.now();
  entity.setStartTime(now);
  entity = em.insert(entity);
  LocalTime plusOneHour = now.plusHours(1);
  entity.setStartTime(plusOneHour);
  entity = em.update(entity);
  entity = em.load(LocalTimeField.class, entity.getId());
  assertEquals(plusOneHour, entity.getStartTime());
}
 
Example 19
Source File: TCKLocalTime.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_plusHours_one() {
    LocalTime t = LocalTime.MIDNIGHT;
    for (int i = 0; i < 50; i++) {
        t = t.plusHours(1);
        assertEquals(t.getHour(), (i + 1) % 24);
    }
}
 
Example 20
Source File: TCKLocalTime.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test_plusHours_fromOne() {
    LocalTime base = LocalTime.of(1, 0);
    for (int i = -50; i < 50; i++) {
        LocalTime t = base.plusHours(i);
        assertEquals(t.getHour(), (1 + i + 72) % 24);
    }
}