GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.YEAR, 2022);
GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.MONTH, Calendar.JANUARY);This example sets the month of the calendar object to January. These methods are part of the java.util package library.