Java program to print present year

Views: 107   

Following program shows you how to print present year.
We can get present year using Year.now().getValue() in java.

import java.time.Year;

public class Basic14 {

    public static void main(String[] args) {

        int year = Year.now().getValue();

        System.out.println("Present year is: " + year);

    }

}

Output:

Present year is: 2018
On By