Java Program to Get the Current Year Using the Get() Method of Calendar Class

You are currently viewing Java Program to Get the Current Year Using the Get() Method of Calendar Class

Java program to get the current year using the get() method of Calendar class

// Java program to get the current year using 
// get() method of Calendar class

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Calendar cal = Calendar.getInstance();

    System.out.println("Current Year: " + cal.get(Calendar.YEAR));
  }
}

Output

Current Year: 2022

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply