Java Code Examples for java.time.LocalDate#until()
The following examples show how to use
java.time.LocalDate#until() .
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: Parser.java From data-generator with MIT License | 5 votes |
private Parser parseDate() { Matcher m = datePattern.matcher(value); if (m.find()) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern(m.group(3)); LocalDate startDate = m.group(1).trim().equals("now") ? LocalDate.now() : LocalDate.parse(m.group(1).trim()); LocalDate endDate = m.group(2).trim().equals("now") ? LocalDate.now() : LocalDate.parse(m.group(2).trim()); int length = (int) startDate.until(endDate, ChronoUnit.DAYS); LocalDate randDate = length > 0 ? startDate.plusDays(rand.nextInt(length + 1)) : startDate.minusDays(rand.nextInt(1 - length)); value = value.replace(m.group(), randDate.format(formatter)); } return this; }
Example 2
Source File: TCKLocalDate.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="until") public void test_periodUntil_LocalDate(int y1, int m1, int d1, int y2, int m2, int d2, int ye, int me, int de) { LocalDate start = LocalDate.of(y1, m1, d1); LocalDate end = LocalDate.of(y2, m2, d2); Period test = start.until(end); assertEquals(test.getYears(), ye); assertEquals(test.getMonths(), me); assertEquals(test.getDays(), de); }
Example 3
Source File: TCKLocalDate.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="until") public void test_periodUntil_LocalDate(int y1, int m1, int d1, int y2, int m2, int d2, int ye, int me, int de) { LocalDate start = LocalDate.of(y1, m1, d1); LocalDate end = LocalDate.of(y2, m2, d2); Period test = start.until(end); assertEquals(test.getYears(), ye); assertEquals(test.getMonths(), me); assertEquals(test.getDays(), de); }
Example 4
Source File: TCKLocalDate.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="until") public void test_periodUntil_LocalDate(int y1, int m1, int d1, int y2, int m2, int d2, int ye, int me, int de) { LocalDate start = LocalDate.of(y1, m1, d1); LocalDate end = LocalDate.of(y2, m2, d2); Period test = start.until(end); assertEquals(test.getYears(), ye); assertEquals(test.getMonths(), me); assertEquals(test.getDays(), de); }
Example 5
Source File: TCKLocalDate.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="until") public void test_periodUntil_LocalDate(int y1, int m1, int d1, int y2, int m2, int d2, int ye, int me, int de) { LocalDate start = LocalDate.of(y1, m1, d1); LocalDate end = LocalDate.of(y2, m2, d2); Period test = start.until(end); assertEquals(test.getYears(), ye); assertEquals(test.getMonths(), me); assertEquals(test.getDays(), de); }
Example 6
Source File: TCKLocalDate.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="until") public void test_periodUntil_LocalDate(int y1, int m1, int d1, int y2, int m2, int d2, int ye, int me, int de) { LocalDate start = LocalDate.of(y1, m1, d1); LocalDate end = LocalDate.of(y2, m2, d2); Period test = start.until(end); assertEquals(test.getYears(), ye); assertEquals(test.getMonths(), me); assertEquals(test.getDays(), de); }
Example 7
Source File: TCKLocalDate.java From hottub with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider="periodUntilUnit") public void test_until_TemporalUnit(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { long amount = date1.until(date2, unit); assertEquals(amount, expected); }
Example 8
Source File: TCKLocalDate.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_until_invalidType() { LocalDate start = LocalDate.of(2010, 6, 30); start.until(LocalTime.of(11, 30), DAYS); }
Example 9
Source File: TCKLocalDate.java From j2objc with Apache License 2.0 | 4 votes |
@Test() @UseDataProvider("data_periodUntilUnit") public void test_until_TemporalUnit_negated(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { long amount = date2.until(date1, unit); assertEquals(amount, -expected); }
Example 10
Source File: TCKLocalDate.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider="periodUntilUnit") public void test_until_TemporalUnit(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { long amount = date1.until(date2, unit); assertEquals(amount, expected); }
Example 11
Source File: TCKLocalDate.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider="periodUntilUnit") public void test_until_TemporalUnit_negated(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { long amount = date2.until(date1, unit); assertEquals(amount, -expected); }
Example 12
Source File: TCKLocalDate.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider="periodUntilUnit") public void test_until_TemporalUnit(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { long amount = date1.until(date2, unit); assertEquals(amount, expected); }
Example 13
Source File: TCKLocalDate.java From j2objc with Apache License 2.0 | 4 votes |
@Test(expected=DateTimeException.class) public void test_until_invalidType() { LocalDate start = LocalDate.of(2010, 6, 30); start.until(LocalTime.of(11, 30), DAYS); }
Example 14
Source File: TCKLocalDate.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider="periodUntilUnit") public void test_until_TemporalUnit(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { long amount = date1.until(date2, unit); assertEquals(amount, expected); }
Example 15
Source File: TCKLocalDate.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider="periodUntilUnit") public void test_until_TemporalUnit_negated(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { long amount = date2.until(date1, unit); assertEquals(amount, -expected); }
Example 16
Source File: TCKLocalDate.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider="periodUntilUnit") public void test_until_TemporalUnit_negated(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { long amount = date2.until(date1, unit); assertEquals(amount, -expected); }
Example 17
Source File: TCKLocalDate.java From j2objc with Apache License 2.0 | 4 votes |
@Test() @UseDataProvider("data_periodUntilUnit") public void test_until_TemporalUnit(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { long amount = date1.until(date2, unit); assertEquals(amount, expected); }
Example 18
Source File: TCKLocalDate.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
@Test(dataProvider="periodUntilUnit") public void test_until_TemporalUnit(LocalDate date1, LocalDate date2, TemporalUnit unit, long expected) { long amount = date1.until(date2, unit); assertEquals(amount, expected); }
Example 19
Source File: TCKLocalDate.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_until_invalidType() { LocalDate start = LocalDate.of(2010, 6, 30); start.until(LocalTime.of(11, 30), DAYS); }
Example 20
Source File: TCKLocalDate.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=DateTimeException.class) public void test_until_invalidType() { LocalDate start = LocalDate.of(2010, 6, 30); start.until(LocalTime.of(11, 30), DAYS); }