Search in sources :

Example 1 with Period

use of java.time.Period in project jdk8u_jdk by JetBrains.

the class TCKPeriod method test_normalized_max.

@Test(expectedExceptions = ArithmeticException.class)
public void test_normalized_max() {
    Period base = Period.of(Integer.MAX_VALUE, 12, 0);
    base.normalized();
}
Also used : Period(java.time.Period) Test(org.testng.annotations.Test)

Example 2 with Period

use of java.time.Period in project jdk8u_jdk by JetBrains.

the class TCKPeriod method test_minusMonths_overflowTooBig.

@Test(expectedExceptions = ArithmeticException.class)
public void test_minusMonths_overflowTooBig() {
    Period test = Period.ofMonths(Integer.MAX_VALUE);
    test.minusMonths(-1);
}
Also used : Period(java.time.Period) Test(org.testng.annotations.Test)

Example 3 with Period

use of java.time.Period in project jdk8u_jdk by JetBrains.

the class TCKLocalDate method test_periodUntil_LocalDate.

@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);
}
Also used : MockSimplePeriod(test.java.time.MockSimplePeriod) Period(java.time.Period) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 4 with Period

use of java.time.Period in project jdk8u_jdk by JetBrains.

the class TCKPeriod method test_minusYears_overflowTooBig.

@Test(expectedExceptions = ArithmeticException.class)
public void test_minusYears_overflowTooBig() {
    Period test = Period.ofYears(Integer.MAX_VALUE);
    test.minusYears(-1);
}
Also used : Period(java.time.Period) Test(org.testng.annotations.Test)

Example 5 with Period

use of java.time.Period in project jdk8u_jdk by JetBrains.

the class TCKPeriod method factory_parse_lowerCase.

@Test(dataProvider = "parseSuccess")
public void factory_parse_lowerCase(String text, Period expected) {
    Period p = Period.parse(text.toLowerCase(Locale.ENGLISH));
    assertEquals(p, expected);
}
Also used : Period(java.time.Period) Test(org.testng.annotations.Test)

Aggregations

Period (java.time.Period)107 Test (org.junit.Test)37 Test (org.testng.annotations.Test)27 LocalDate (java.time.LocalDate)20 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)8 Duration (java.time.Duration)7 LocalDateTime (java.time.LocalDateTime)6 ZonedDateTime (java.time.ZonedDateTime)6 Date (java.util.Date)6 DateTimeFormatter (java.time.format.DateTimeFormatter)5 Test (org.junit.jupiter.api.Test)5 Instant (java.time.Instant)4 LocalTime (java.time.LocalTime)4 ZoneId (java.time.ZoneId)4 DateTimeParseException (java.time.format.DateTimeParseException)4 TemporalAmount (java.time.temporal.TemporalAmount)4 Arrays (java.util.Arrays)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 ArrayList (java.util.ArrayList)3