OffsetDateTime getYear()
gets the year field. This method returns the primitive int value for the year.
getYear
has the following syntax.
public int getYear()
The following example shows how to use getYear
.
import java.time.OffsetDateTime; 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.