title: Check specific date and comparing start time and end time based on the timepicker and datepicker if overlaps
body: <p>I need to do a room booking app. I want to take the date from the datepicker value, then start time and end time from the timepicker value.</p>
  
  <p>For that, I want to check for the selected date. Then, check if the start time and end time overlaps in any way whether start time, end time or in between on the selected date. I have been searching for the solution but did not find one.</p>
  
  <p>Example :</p>
  
  <p>User A : date=27 may 2013 start time=10pm end time=12pm</p>
  
  <p>User B : date=28 may 2013 start time=10pm end time=12pm</p>
  
  <p>if I am User C,and I also want that 10-12pm time slot at 27 may 2013,how do I compare for the date,then compare the start time and end time if the time slot is already taken by User A.</p>
  
  <p>Hopefully someone can point me out in right the direction - I'm new in Android. Any help would be appreciated,thanks!</p>
  
  <p>My Timepicker code:</p>
  
  <pre><code>private TimePickerDialog.OnTimeSetListener timePickerStartListener =  new TimePickerDialog.OnTimeSetListener() {
      public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) {
          hour = selectedHour;
          minute = selectedMinute;
  
          // set current time into textview
          textStartTime.setText(new StringBuilder().append(padding_str(hour)).append(":").append(padding_str(minute)));
  
      }
  };
  
  private TimePickerDialog.OnTimeSetListener timePickerEndListener =  new TimePickerDialog.OnTimeSetListener() {
      public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) {
          hour = selectedHour;
          minute = selectedMinute;
  
          // set current time into textview           
          textEndTime.setText(new StringBuilder().append(padding_str(hour)).append(":").append(padding_str(minute)));
  
      }
  };
  
  private static String padding_str(int c) {
      if (c &gt;= 10)
         return String.valueOf(c);
      else
         return "0" + String.valueOf(c);
  }
  </code></pre>
  
  <p>My DatePicker code:</p>
  
  <pre><code>private DatePickerDialog.OnDateSetListener datePickerListener 
              = new DatePickerDialog.OnDateSetListener() {
  
      // when dialog box is closed, below method will be called.
      public void onDateSet(DatePicker view, int selectedYear,
              int selectedMonth, int selectedDay) {
          year = selectedYear;
          month = selectedMonth;
          day = selectedDay;
  
          // set selected date into textview
          tvDisplayDate.setText(new StringBuilder().append(month + 1)
             .append("-").append(day).append("-").append(year)
             .append(" "));
      }
  };
  
  
  
  @Override
  protected Dialog onCreateDialog(int id) {
      switch (id) {
      case DATE_DIALOG_ID:
          return new DatePickerDialog(this, datePickerListener, year, month, day);
      case START_TIME_DIALOG_ID:
          return new TimePickerDialog(this, timePickerStartListener, hour, minute, false);
      case END_TIME_DIALOG_ID:
          return new TimePickerDialog(this, timePickerEndListener, hour, minute, false);
      }
      return null;
  }
  </code></pre>