Easy learning with example program codes

Java 8 Year class

The java.time.Year class is an immutable date-time object that represents a year.

Java Year class methods

Method Description
LocalDate atDay(int dayOfYear) It is used to combine this year with a day-of-year to create a LocalDate.
String format(DateTimeFormatter formatter) It is used to format this year using the specified formatter.
int get(TemporalField field) It is used to get the value of the specified field from this year as an int.
boolean isAfter(Year other) It is used to check if this year is after the specified year.
boolean isBefore(Year other) It is used to check if this year is before the specified year.
boolean isLeap() It is used to check if the year is a leap year, according to the ISO proleptic calendar system rules.
int length() It is used to get the length of this year in days.
static Year now() It is used to obtain the current year from the system clock in the default time-zone.


package com.codesjava;
import java.time.Year;
public class TestExample {
	public static void main(String args[]){
	    Year year =;  
	    //atDay() method
	    //length() method
	    //isLeap() method


Posted in Date   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki