OffsetDateTime getYear() example
Description
OffsetDateTime getYear()
gets the year field. This method returns the primitive int value for the year.
Syntax
getYear
has the following syntax.
public int getYear()
Example
The following example shows how to use getYear
.
import java.time.OffsetDateTime;
// w ww .j a v a2s . co m
public class Main {
public static void main(String[] args) {
OffsetDateTime o = OffsetDateTime.now();
int l = o.getYear();
System.out.println(l);
}
}
The code above generates the following result.