0

How i get number day interval from two date picker dialog. I am have first date picker for hotel checkin and the second date picker dialog for hotel checkout. My problem i want to get duration from hotel checkout and hotel checkin. This my two date picker dialog...

public void hotelCheckIn(View view) {

        calendar1 = Calendar.getInstance();
        Year = calendar1.get(Calendar.YEAR);
        Month = calendar1.get(Calendar.MONTH);
        Day = calendar1.get(Calendar.DAY_OF_MONTH);
        Day1 = calendar1.get(Calendar.DAY_OF_WEEK);
        DatePickerDialog datePickerDialog = new DatePickerDialog(this,
                new DatePickerDialog.OnDateSetListener() {

                    @Override
                    public void onDateSet(DatePicker view, int year,
                                          int monthOfYear, int dayOfMonth) {

                        mTglCheckIn.setText(dayOfMonth + "-" + (monthOfYear 
                    + 1) + "-" + year);
                    }
                }, Year, Month, Day);
      datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() 
      - 1000);
        datePickerDialog.show();
      }
    }

  public void tanggalCheckout(View view) {

        calendar2 = Calendar.getInstance();
        Year = calendar2.get(Calendar.YEAR);
        Month = calendar2.get(Calendar.MONTH);
        Day = calendar2.get(Calendar.DAY_OF_MONTH);
        Day1 = calendar2.get(Calendar.DAY_OF_WEEK);
        DatePickerDialog datePickerDialog = new DatePickerDialog(this,
                new DatePickerDialog.OnDateSetListener() {

                    @Override
                    public void onDateSet(DatePicker view, int year,
                                          int monthOfYear, int dayOfMonth) {

                        mTglCheckOut.setText(dayOfMonth + "-" + (monthOfYear 
       + 1) + "-" + year);
                    }
                }, Year, Month, Day);            
    datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 
    1000);
        datePickerDialog.show();
    }
 }

Thanks before guys!

Hemant Parmar
  • 3,924
  • 7
  • 25
  • 49

0 Answers0