days = weeks * 7 + (dow - dateDow);
}
date = date.plus(days, DAYS);
if (resolverStyle == ResolverStyle.STRICT) {
if (date.getLong(this) != fieldValues.get(this)) {
throw new DateTimeException("Strict mode rejected date parsed to a different year");
}
}
fieldValues.remove(this);
fieldValues.remove(weekDef.weekOfWeekBasedYear);
fieldValues.remove(DAY_OF_WEEK);
return date;
}
if (fieldValues.containsKey(YEAR) == false) {
return null;
}
int isoDow = DAY_OF_WEEK.checkValidIntValue(fieldValues.get(DAY_OF_WEEK));
int dow = Jdk8Methods.floorMod(isoDow - sow, 7) + 1;
int year = YEAR.checkValidIntValue(fieldValues.get(YEAR));
Chronology chrono = Chronology.from(partialTemporal); // defaults to ISO
if (rangeUnit == MONTHS) { // week-of-month
if (fieldValues.containsKey(MONTH_OF_YEAR) == false) {
return null;
}
final long value = fieldValues.remove(this);
ChronoLocalDate date;
long days;
if (resolverStyle == ResolverStyle.LENIENT) {
long month = fieldValues.get(MONTH_OF_YEAR);
date = chrono.date(year, 1, 1);
date = date.plus(month - 1, MONTHS);
int dateDow = localizedDayOfWeek(date, sow);
long weeks = value - localizedWeekOfMonth(date, dateDow);
days = weeks * 7 + (dow - dateDow);
} else {
int month = MONTH_OF_YEAR.checkValidIntValue(fieldValues.get(MONTH_OF_YEAR));
date = chrono.date(year, month, 8);
int dateDow = localizedDayOfWeek(date, sow);
int wom = range.checkValidIntValue(value, this);
long weeks = wom - localizedWeekOfMonth(date, dateDow);
days = weeks * 7 + (dow - dateDow);
}
date = date.plus(days, DAYS);
if (resolverStyle == ResolverStyle.STRICT) {
if (date.getLong(MONTH_OF_YEAR) != fieldValues.get(MONTH_OF_YEAR)) {
throw new DateTimeException("Strict mode rejected date parsed to a different month");
}
}
fieldValues.remove(this);
fieldValues.remove(YEAR);
fieldValues.remove(MONTH_OF_YEAR);
fieldValues.remove(DAY_OF_WEEK);
return date;
} else if (rangeUnit == YEARS) { // week-of-year
final long value = fieldValues.remove(this);
ChronoLocalDate date = chrono.date(year, 1, 1);
long days;
if (resolverStyle == ResolverStyle.LENIENT) {
int dateDow = localizedDayOfWeek(date, sow);
long weeks = value - localizedWeekOfYear(date, dateDow);
days = weeks * 7 + (dow - dateDow);
} else {
int dateDow = localizedDayOfWeek(date, sow);
int woy = range.checkValidIntValue(value, this);
long weeks = woy - localizedWeekOfYear(date, dateDow);
days = weeks * 7 + (dow - dateDow);
}
date = date.plus(days, DAYS);
if (resolverStyle == ResolverStyle.STRICT) {
if (date.getLong(YEAR) != fieldValues.get(YEAR)) {
throw new DateTimeException("Strict mode rejected date parsed to a different year");
}
}
fieldValues.remove(this);
fieldValues.remove(YEAR);
fieldValues.remove(DAY_OF_WEEK);