Java program to print present year
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