I want to select the previous day in a calendar. For example, if I have 02-28-2018 I need to set 27 automatically.
I have tried the below code but it fails when the date is 1st.
String currentDate = new SimpleDateFormat("dd").format(new Date());
int previousDay = Integer.parseInt(currentDate) - 1;