source file name: datedemo3.java

import java.util.*;

class datedemo3

{

public static void main(String as[])

{

String mon[]={"Jan","Feb","March","April","May","June",

"July","August","Sep","Oct","Nov","Dec"};


System.out.println("Date and Time using Calendar class program: ");


Calendar curr = Calendar.getInstance();


System.out.println("Today's Date is: "+curr.get(Calendar.DATE)+"-"+mon[curr.get(Calendar.MONTH)]+"-"+curr.get(Calendar.YEAR));

System.out.println("Today's Time is: "+curr.get(Calendar.HOUR)+": "+curr.get(Calendar.MINUTE)+": "+curr.get(Calendar.SECOND));


curr.set(2020,11,06);

System.out.println("updated Date is: "+curr.get(Calendar.DATE)+"-"+mon[curr.get(Calendar.MONTH)]+"-"+curr.get(Calendar.YEAR));

}

}


output:
D:\JavaPrograms\Misc>javac datedemo3.java

D:\JavaPrograms\Misc>java datedemo3
Date and Time using Calendar class program:
Today's Date is: 4-June-2021
Today's Time is: 0: 14: 19
updated Date is: 6-Dec-2020