title: How to get previous and next day's dates in android?
body: <p>I created a layout with three <code>Buttons</code>. My idea is to use these three buttons as a datepicker. Those three buttons are <code>-</code>,<code>Today</code>,<code>+</code>.
  If I press the today button displays today's date. When I press <code>-</code> it displays yesterdays date. If I press <code>+</code> it displays tomorrow's date. No problem. But it only works once. My requirement is to as long as I press <code>-</code> it has to display previous day's dates i.e <code>19-Aug-2015</code>,<code>18-Aug-2015</code>,<code>17-Aug-2015</code>,etc., My code is</p>
  
  <pre><code> imgtoday.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              googleMap.clear();
              Date date1=new Date(System.currentTimeMillis());
              SimpleDateFormat sdf=new SimpleDateFormat("dd-MMM-yyyy");
              String date=sdf.format(date1);
              drawRoute(date);
              imgHistory.setClickable(false);
              imgHistory.setBackgroundResource(R.drawable.btn_disabled);
              calculateDistance(date);
          }
      });
  
      previousDay=(Button)findViewById(R.id.button9);
      nextDay=(Button)findViewById(R.id.button11);
  
      previousDay.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              googleMap.clear();
              Date date1=new Date(System.currentTimeMillis() - (1000 * 60 * 60 * 24));
              SimpleDateFormat sdf=new SimpleDateFormat("dd-MMM-yyyy");
              String date=sdf.format(date1);
              drawRoute(date);
              calculateDistance(date);
          }
      });
  
      nextDay.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              googleMap.clear();
              Date date1=new Date(System.currentTimeMillis() + (1000 * 60 * 60 * 24));
              SimpleDateFormat sdf=new SimpleDateFormat("dd-MMM-yyyy");
              String date=sdf.format(date1);
              drawRoute(date);
              calculateDistance(date);
          }
      });
  </code></pre>
  
  <p>Anyone please help. Thanks.</p>