ZonedDateTime getYear() example
Description
ZonedDateTime getYear()
gets the year field.
Syntax
getYear
has the following syntax.
public int getYear()
Example
The following example shows how to use getYear
.
import java.time.ZonedDateTime;
/*w w w . j av a 2s . c o m*/
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.