ZonedDateTime getYear()
gets the year field.
getYear
has the following syntax.
public int getYear()
The following example shows how to use getYear
.
import java.time.ZonedDateTime; public class Main { public static void main(String[] args) { ZonedDateTime dateTime =ZonedDateTime.now(); System.out.println(dateTime.getYear()); } }
The code above generates the following result.