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);
}
}
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);
}
}
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);
}
}
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);
}
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);
}
Aggregations