Search in sources :

Example 71 with LocalDate

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

the class TestIsoWeekFields method test_addTo_weekBasedYears.

@Test(dataProvider = "fields")
public void test_addTo_weekBasedYears(TemporalField weekField, TemporalField yearField) {
    // tests every day from 2012 to 2016 inclusive
    LocalDate date = LocalDate.of(2012, 1, 2);
    int wby = 2012;
    int week = 1;
    int dow = 1;
    for (int i = 1; i <= ((52 + 52 + 52 + 53 + 52) * 7); i++) {
        for (int j = -5; j <= 5; j++) {
            LocalDate adjusted = IsoFields.WEEK_BASED_YEARS.addTo(date, j);
            assertEquals(adjusted.get(yearField), wby + j);
            assertEquals(adjusted.get(DAY_OF_WEEK), dow);
            assertEquals(adjusted.get(weekField), (week == 53 && wbyLen(wby + j) == 52 ? 52 : week), "" + date + " " + adjusted);
        }
        if (dow == 7) {
            dow = 1;
            week++;
        } else {
            dow++;
        }
        if (week > wbyLen(wby)) {
            week = 1;
            wby++;
        }
        date = date.plusDays(1);
    }
}
Also used : LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 72 with LocalDate

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

the class TestIsoWeekFields method test_adjustInto_wby.

@Test(dataProvider = "fields")
public void test_adjustInto_wby(TemporalField weekField, TemporalField yearField) {
    // tests every day from 2012 to 2016 inclusive
    LocalDate date = LocalDate.of(2012, 1, 2);
    int wby = 2012;
    int week = 1;
    int dow = 1;
    for (int i = 1; i <= ((52 + 52 + 52 + 53 + 52) * 7); i++) {
        for (int j = 2004; j <= 2015; j++) {
            LocalDate adjusted = yearField.adjustInto(date, j);
            assertEquals(adjusted.get(yearField), j);
            assertEquals(adjusted.get(DAY_OF_WEEK), dow);
            assertEquals(adjusted.get(weekField), (week == 53 && wbyLen(j) == 52 ? 52 : week), "" + date + " " + adjusted);
        }
        if (dow == 7) {
            dow = 1;
            week++;
        } else {
            dow++;
        }
        if (week > wbyLen(wby)) {
            week = 1;
            wby++;
        }
        date = date.plusDays(1);
    }
}
Also used : LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 73 with LocalDate

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

the class TestIsoWeekFields method test_adjustInto_dow.

@Test(dataProvider = "fields")
public void test_adjustInto_dow(TemporalField weekField, TemporalField yearField) {
    // tests every day from 2012 to 2016 inclusive
    LocalDate date = LocalDate.of(2012, 1, 2);
    int wby = 2012;
    int week = 1;
    int dow = 1;
    for (int i = 1; i <= ((52 + 52 + 52 + 53 + 52) * 7); i++) {
        for (int j = 1; j <= 7; j++) {
            LocalDate adjusted = DAY_OF_WEEK.adjustInto(date, j);
            assertEquals(adjusted.get(DAY_OF_WEEK), j);
            assertEquals(adjusted.get(weekField), week);
            assertEquals(adjusted.get(yearField), wby);
        }
        if (dow == 7) {
            dow = 1;
            week++;
        } else {
            dow++;
        }
        if (week > wbyLen(wby)) {
            week = 1;
            wby++;
        }
        date = date.plusDays(1);
    }
}
Also used : LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 74 with LocalDate

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

the class TCKLocalDate method test_plusDays_maximum.

@Test
public void test_plusDays_maximum() {
    LocalDate t = LocalDate.of(Year.MAX_VALUE, 12, 30).plusDays(1);
    LocalDate expected = LocalDate.of(Year.MAX_VALUE, 12, 31);
    assertEquals(t, expected);
}
Also used : LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 75 with LocalDate

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

the class TCKLocalDate method test_atTime_int_int_int_secondTooSmall.

@Test(expectedExceptions = DateTimeException.class)
public void test_atTime_int_int_int_secondTooSmall() {
    LocalDate t = LocalDate.of(2008, 6, 30);
    t.atTime(11, 30, -1);
}
Also used : LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Aggregations

LocalDate (java.time.LocalDate)1513 Test (org.junit.Test)472 Test (org.testng.annotations.Test)372 LocalDateTime (java.time.LocalDateTime)155 LocalTime (java.time.LocalTime)126 Date (java.util.Date)99 DateTimeFormatter (java.time.format.DateTimeFormatter)96 Ignore (org.junit.Ignore)94 ArrayList (java.util.ArrayList)87 BigDecimal (java.math.BigDecimal)69 Instant (java.time.Instant)56 ZonedDateTime (java.time.ZonedDateTime)55 Test (org.junit.jupiter.api.Test)54 List (java.util.List)50 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)46 HashMap (java.util.HashMap)44 Member (cz.metacentrum.perun.core.api.Member)41 ZoneId (java.time.ZoneId)40 TemporalField (java.time.temporal.TemporalField)40 Attribute (cz.metacentrum.perun.core.api.Attribute)39