Java Code Examples for java.time.LocalDateTime#plusHours()
The following examples show how to use
java.time.LocalDateTime#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 jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Test public void test_plusHours_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); for (int i = 0; i < 50; i++) { t = t.plusHours(1); if ((i + 1) % 24 == 0) { d = d.plusDays(1); } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), (i + 1) % 24); } }
Example 2
Source File: TCKLocalDateTime.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@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 3
Source File: TCKLocalDateTime.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test public void test_plusHours_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); for (int i = 0; i < 50; i++) { t = t.plusHours(1); if ((i + 1) % 24 == 0) { d = d.plusDays(1); } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), (i + 1) % 24); } }
Example 4
Source File: TCKLocalDateTime.java From hottub with GNU General Public License v2.0 | 6 votes |
@Test public void test_plusHours_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); for (int i = 0; i < 50; i++) { t = t.plusHours(1); if ((i + 1) % 24 == 0) { d = d.plusDays(1); } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), (i + 1) % 24); } }
Example 5
Source File: TCKLocalDateTime.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@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 openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@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 openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test public void test_plusHours_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); for (int i = 0; i < 50; i++) { t = t.plusHours(1); if ((i + 1) % 24 == 0) { d = d.plusDays(1); } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), (i + 1) % 24); } }
Example 8
Source File: TCKLocalDateTime.java From j2objc with Apache License 2.0 | 6 votes |
@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 9
Source File: TCKLocalDateTime.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@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 10
Source File: TCKLocalDateTime.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@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 11
Source File: TCKLocalDateTime.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@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 12
Source File: TCKLocalDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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 13
Source File: TCKLocalDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@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 14
Source File: TCKLocalDateTime.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test public void test_plusHours_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); for (int i = 0; i < 50; i++) { t = t.plusHours(1); if ((i + 1) % 24 == 0) { d = d.plusDays(1); } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), (i + 1) % 24); } }
Example 15
Source File: TCKLocalDateTime.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void test_plusHours_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); for (int i = 0; i < 50; i++) { t = t.plusHours(1); if ((i + 1) % 24 == 0) { d = d.plusDays(1); } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), (i + 1) % 24); } }
Example 16
Source File: TCKLocalDateTime.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@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 17
Source File: TCKLocalDateTime.java From hottub with GNU General Public License v2.0 | 6 votes |
@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 18
Source File: TCKLocalDateTime.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Test public void test_plusHours_one() { LocalDateTime t = TEST_2007_07_15_12_30_40_987654321.with(LocalTime.MIDNIGHT); LocalDate d = t.toLocalDate(); for (int i = 0; i < 50; i++) { t = t.plusHours(1); if ((i + 1) % 24 == 0) { d = d.plusDays(1); } assertEquals(t.toLocalDate(), d); assertEquals(t.getHour(), (i + 1) % 24); } }
Example 19
Source File: ImportDateTime.java From axelor-open-suite with GNU Affero General Public License v3.0 | 5 votes |
public LocalDateTime updateHour(LocalDateTime datetime, String hour) { if (!Strings.isNullOrEmpty(hour)) { Matcher matcher = patternMonth.matcher(hour); if (matcher.find()) { Long hours = Long.parseLong(matcher.group()); if (hour.startsWith("+")) datetime = datetime.plusHours(hours); else if (hour.startsWith("-")) datetime = datetime.minusHours(hours); else datetime = datetime.withHour(hours.intValue()); } } return datetime; }
Example 20
Source File: JavaUtilTimeUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void getTimeSpan() { LocalDateTime now = LocalDateTime.now(); LocalDateTime hourLater = now.plusHours(1); Duration span = Duration.between(now, hourLater); assertThat(span).isEqualTo(Duration.ofHours(1)); }