Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, 2022);In this example, the Calendar.getInstance() method returns a new Calendar instance set to the current date and time in the default time zone. The set() method is then called on this instance and passed two arguments: the constant Calendar.YEAR, which represents the year field, and the value 2022, which sets the year to 2022. Package Library: The set() method is part of the java.util package library in Java. This library provides a wide range of utility classes for handling dates, times, and other related functionalities.