To get yesterdays date and format it, you have 3 choices:
// Use Java 8+ LocalDate
java.time.LocalDate yesterday = LocalDate.now().minusDays(1);
String text = yesterday.format(DateTimeFormatter.ofPattern("MM/dd/uuuu"));
// Use Joda-Time (3rd-party library)
org.joda.time.LocalDate yesterday = LocalDate.now().minusDays(1);
String text = yesterday.toString("MM/dd/yyyy");
// Use Calendar (all Java versions, no 3rd-party library)
java.util.Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_ON_MONTH, -1);
java.util.Date yesterday = cal.getTime();
String text = new SimpleDateFormat("MM/dd/yyyy").format(yesterday);
Note that Calendar
version still produces a "date" value with time-of-day. Extra code would be needed to clear the time fields.