Package java.time

Examples of java.time.YearMonth


    constraint = new PastValidatorForYearMonth();
  }

  @Test
  public void testIsValid() {
    YearMonth future = YearMonth.now().plusYears( 1 );
    YearMonth past = YearMonth.now().minusYears( 1 );

    assertTrue( constraint.isValid( null, null ), "null fails validation." );
    assertTrue( constraint.isValid( past, null ), "Past YearMonth '" + past + "' fails validation.");
    assertFalse( constraint.isValid( future, null ), "Future YearMonth '" + future + "' validated as past.");
  }
View Full Code Here


  /**
   * {@link java.time.YearMonth} is a holder for an associated year and month, such as that used for expiry dates.
   */
  @Test
  public void testYearMonthHolder() {
    final YearMonth expiry = YearMonth.of(2014, Month.SEPTEMBER);
    final LocalDate localDate = LocalDate.of(expiry.getYear(), expiry.getMonthValue(), 1);

    assertThat(localDate.getMonth(), is(expiry.getMonth()));
  }
View Full Code Here

TOP

Related Classes of java.time.YearMonth

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.