import java.util.Calendar;
import java.util.GregorianCalendar;
public class Main {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance(); //Get the current date and time
//Print out a constant from the calendar
System.out.println("Year: " + calendar.get(Calendar.YEAR));
//Print out the full date
System.out.println("Date: " + (calendar.get(Calendar.MONTH) + 1) + " " + calendar.get(Calendar.DATE) + " " + calendar.get(Calendar.YEAR));
//Time
System.out.println("Time: " + calendar.get(Calendar.HOUR) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND));
//If you want to show the actual month in english
String monnths[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
System.out.println("Month: " + monnths[calendar.get(Calendar.MONTH)]);
//Setting the values of the Calendar
calendar.set(2019, 0, 16);
calendar.set(Calendar.SECOND, 25);
calendar.set(Calendar.HOUR, 11);
System.out.println("Updated Date and Time");
System.out.println("Date: " + (calendar.get(Calendar.MONTH) + 1) + " " + calendar.get(Calendar.DATE) + " " + calendar.get(Calendar.YEAR));
System.out.println("Time: " + calendar.get(Calendar.HOUR) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND));
System.out.println(calendar.getTime()); //Another simple way to get time or date object
//The Gregorian Calendar
GregorianCalendar gcal = new GregorianCalendar(); //Use your current time
GregorianCalendar gcal2 = new GregorianCalendar(2019, 2, 14);
//Since gregorian calendar is concrete, you can instantiate ^
}
}