I have a date which is coming in the form of 21,23,24,25.....
What I want is to subtract 4 days from current day of the month.
My attempt is reported below but it is giving me dates in the form of dd/mm/yyyy
. I just want the day.
Calendar cal=Calendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, -4);
Date curdteMinusFourDays=cal.getTime();
String curdteMinusFourDaysStr=curdteMinusFourDays.toString();
System.out.println(curdteMinusFourDays);
tripDate.click();
List<WebElement> listofdates=CommonBrowserSetup.driver.findElements(By.tagName("td"));
for (int i=1;i<=listofdates.size();i++){
System.out.println(listofdates.get(i).getText());
String d1=listofdates.get(i).getText();
if(d1.contains(curdteMinusFourDaysStr)){
listofdates.get(i).click();
break;
}
}