Java Code Examples for java.time.YearMonth#until()

The following examples show how to use java.time.YearMonth#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: MonthsBetween.java    From RestServices with Apache License 2.0 6 votes vote down vote up
@Override
public java.lang.Long executeAction() throws Exception
{
	// BEGIN USER CODE
    LocalDate localDate1 = date1.toInstant()
               .atZone(ZoneId.systemDefault())
               .toLocalDate();
    LocalDate localDate2 = date2.toInstant()
               .atZone(ZoneId.systemDefault())
               .toLocalDate();
    YearMonth m1 = YearMonth.from(localDate1);
    YearMonth m2 = YearMonth.from(localDate2);

    return m1.until(m2, ChronoUnit.MONTHS) + 1;
	// END USER CODE
}
 
Example 2
Source File: TCKYearMonth.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit_negated(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym2.until(ym1, unit);
    assertEquals(amount, -expected);
}
 
Example 3
Source File: TCKYearMonth.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym1.until(ym2, unit);
    assertEquals(amount, expected);
}
 
Example 4
Source File: TCKYearMonth.java    From j2objc with Apache License 2.0 4 votes vote down vote up
@Test(expected=DateTimeException.class)
public void test_until_invalidType() {
    YearMonth start = YearMonth.of(2010, 6);
    start.until(LocalTime.of(11, 30), MONTHS);
}
 
Example 5
Source File: TCKYearMonth.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_until_invalidType() {
    YearMonth start = YearMonth.of(2010, 6);
    start.until(LocalTime.of(11, 30), MONTHS);
}
 
Example 6
Source File: TCKYearMonth.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit_negated(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym2.until(ym1, unit);
    assertEquals(amount, -expected);
}
 
Example 7
Source File: TCKYearMonth.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym1.until(ym2, unit);
    assertEquals(amount, expected);
}
 
Example 8
Source File: TCKYearMonth.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_until_invalidType() {
    YearMonth start = YearMonth.of(2010, 6);
    start.until(LocalTime.of(11, 30), MONTHS);
}
 
Example 9
Source File: TCKYearMonth.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit_negated(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym2.until(ym1, unit);
    assertEquals(amount, -expected);
}
 
Example 10
Source File: TCKYearMonth.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym1.until(ym2, unit);
    assertEquals(amount, expected);
}
 
Example 11
Source File: TCKYearMonth.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_until_invalidType() {
    YearMonth start = YearMonth.of(2010, 6);
    start.until(LocalTime.of(11, 30), MONTHS);
}
 
Example 12
Source File: TCKYearMonth.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_until_invalidType() {
    YearMonth start = YearMonth.of(2010, 6);
    start.until(LocalTime.of(11, 30), MONTHS);
}
 
Example 13
Source File: TCKYearMonth.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym1.until(ym2, unit);
    assertEquals(amount, expected);
}
 
Example 14
Source File: TCKYearMonth.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit_negated(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym2.until(ym1, unit);
    assertEquals(amount, -expected);
}
 
Example 15
Source File: TCKYearMonth.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym1.until(ym2, unit);
    assertEquals(amount, expected);
}
 
Example 16
Source File: TCKYearMonth.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(expectedExceptions=DateTimeException.class)
public void test_until_invalidType() {
    YearMonth start = YearMonth.of(2010, 6);
    start.until(LocalTime.of(11, 30), MONTHS);
}
 
Example 17
Source File: TCKYearMonth.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit_negated(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym2.until(ym1, unit);
    assertEquals(amount, -expected);
}
 
Example 18
Source File: TCKYearMonth.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym1.until(ym2, unit);
    assertEquals(amount, expected);
}
 
Example 19
Source File: TCKYearMonth.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit_negated(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym2.until(ym1, unit);
    assertEquals(amount, -expected);
}
 
Example 20
Source File: TCKYearMonth.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit_negated(YearMonth ym1, YearMonth ym2, TemporalUnit unit, long expected) {
    long amount = ym2.until(ym1, unit);
    assertEquals(amount, -expected);
}