I’ll give you 2 example.

Example 1:

SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
Calendar cal = Calendar.getInstance();
System.out.println(df.format(cal.getTime()));

Or we can use Date instead of Calendar, like this:

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Date dt = new Date();
System.out.println(sdf.format(dt));

You also can change date format like “yyyy/MM/dd HH:mm:ss”.

Example 2:

Calendar cal = Calendar.getInstance();
int day = cal.get(Calendar.DATE);
int month = cal.get(Calendar.MONTH) + 1;
int year = cal.get(Calendar.YEAR);
int dow = cal.get(Calendar.DAY_OF_WEEK);
int dom = cal.get(Calendar.DAY_OF_MONTH);
int doy = cal.get(Calendar.DAY_OF_YEAR);

System.out.println("Current Date: " + cal.getTime());
System.out.println("Day: " + day);
System.out.println("Month: " + month);
System.out.println("Year: " + year);
System.out.println("Day of Week: " + dow);
System.out.println("Day of Month: " + dom);
System.out.println("Day of Year: " + doy);

Now, lets try:mrgreen: