title: Validating two dates on android studio
body: <p>I need to validate 2 date, one is picked by the user and the other is the one that I get form the calendar... this is what I try so far without success:</p>
  
  <pre><code>Calendar c = Calendar.getInstance();
  if(!DateIsOlder(txtVwAppointmentDate.getText(), c.getTime())) {
              try {
                    //My code
                  }  
  
  public static boolean DateIsOlder(CharSequence date1, Date date2){
      //SimpleDateFormat Date2 = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz -HH:mm yyyy", Locale.ENGLISH);
      SimpleDateFormat dfDate = new SimpleDateFormat("dd/mm/yyyy", Locale.ENGLISH);
      boolean isOlder = false;
      try{
          //Date newDate = (Date)Date2.parse(date2);
          if(dfDate.parse(String.valueOf(date1)).before(dfDate.format(date2))){
          isOlder = true;
          }
          else if (dfDate.parse(String.valueOf(date1)).equals(dfDate.format(date2))){
          isOlder = false;
          }
          else {
              isOlder = false;
          }
      }catch (Exception e){
          e.printStackTrace();
      }
      return isOlder;
  }
  </code></pre>
  
  <p>The error is on .before(dfDate.format(date2)) , it says :
  Error:(484, 51) error: method before in class Date cannot be applied to given types;
  required: Date
  found: String
  reason: actual argument String cannot be converted to Date by method invocation conversion</p>
  
  <p>and if you can see, on the else if I compare both dates if they are equal and compiler do not show any error on this line:</p>
  
  <pre><code>else if (dfDate.parse(String.valueOf(date1)).equals(dfDate.format(date2)))
  </code></pre>
  
  <p>Also I try to change it to Date but no successs... any Idea to help me to solve this issue? thanks.</p>