i have a variable which gives me random dates in this format `"dd/MM/yyyy".I want my code to add 5 days in this date like this.
05/12/2022 ---> 10/12/2022
The code i found on internet is this
String stringDate="05/12/2022";
Date date1=new SimpleDateFormat("dd/MM/yyyy").parse(stringDate);
Calendar cal = Calendar.getInstance();
cal.setTime(date1);
cal.add(Calendar.DATE, 5);
Date dateWith5Days = cal.getTime();
System.out.println(dateWith5Days+" is the date after adding 5 days.");
Output
Sat Dec 10 00:00:00 IST 2022 is the date after adding 5 days.
Expected output
10/12/2022 is the date after adding 5 days.