Returns an adjusted copy of this year for the specified temporal adjuster.
Returns a copy of this year with the specified field set to a new value.

package com.logicbig.example.year;
import java.time.Year;
import java.time.temporal.ChronoField;
public class WithExample2 {
public static void main(String... args) {
Year y = Year.of(2011);
System.out.println(y);
for (ChronoField chronoField : ChronoField.values()) {
if (y.isSupported(chronoField)) {
Year y2 = y.with(chronoField, 1);
System.out.printf("%15s => %s%n", chronoField.name(), y2);
}
}
}
}
Output
2011
YEAR_OF_ERA => 1
YEAR => 1
ERA => 2011