title: How to check if date exceeds more than seven days
body: <p>I would like to check if two date exceeds a week, like, check if two dates have seven days,</p>
  
  <p>at point the data range should be within a week only(7 Days).</p>
  
  <p>i have tried something like this,</p>
  
  <pre><code>import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  
  public class IsDateRangeExceedsWeek 
  {
      public static void main( String[] args ) 
      {
          try{
  
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
              Date fromDate = sdf.parse("2015-05-01");
              Date toDate = sdf.parse("2015-05-07");
  
              System.out.println(sdf.format(fromDate));
              System.out.println(sdf.format(toDate));
  
              if(fromDate.compareTo(toDate)&gt;0){
                  System.out.println("From Date should be less than To Date");
              } else if(fromDate.compareTo(toDate)==0){
                  System.out.println("From Date is equal to To Date");
              } 
  
          }catch(ParseException ex){
              ex.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>Could some one help ?</p>