title: Java Get One Day Before Specific Date
body: <p>I have a String expired date. But I need to perform some SQL statement the day before expired date falls. I get my expired date and by:</p>
  
  <pre><code>SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
  String expiredDate = null;
  String currentDate = dateFormat.format(new Date());
  Calendar cal = Calendar.getInstance();
  
  try {
              cal.setTime(dateFormat.parse(loanDate));
              cal.add(Calendar.WEEK_OF_YEAR, 2);
              expiredDate = dateFormat.format(cal.getTimeInMillis());
              cal.add(Calendar.WEEK_OF_YEAR, -2);
          } catch (ParseException e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>Then, I got an if statement to perform SQL statement:</p>
  
  <pre><code>if(expiredDate.equals(currentDate)){
                          promptExtensionDialog();
                      }
  </code></pre>
  
  <p>What I am trying to achieve is for the if statement, instead of the expiredDate itself, I need to get one day before the expired date and compare with the current date. I wonder how to achieve this?</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>try {
                          cal.setTime(dateFormat.parse(expiredDate));
                          cal.add(Calendar.DATE, -1);
                          expiredDate = dateFormat.format(cal.getTimeInMillis());
                      } catch (ParseException e) {
                          e.printStackTrace();
                      }
                      Toast.makeText(LoanBook.this,
                              expiredDate, Toast.LENGTH_LONG)
                              .show();
  </code></pre>
  
  <p>This returns me the next date instead of previous date. Do you have any ideas?</p>