ZonedDateTime withYear(int year)
returns a copy of this ZonedDateTime with the year value altered.
withYear
has the following syntax.
public ZonedDateTime withYear(int year)
The following example shows how to use withYear
.
import java.time.ZonedDateTime; public class Main { public static void main(String[] args) { ZonedDateTime dateTime =ZonedDateTime.now(); dateTime = dateTime.withYear(2000); System.out.println(dateTime); } }
The code above generates the following result.