从两个日期选择器对话框中获取号码日间隔

时间:2018-02-27 09:09:56

标签: android datepicker

我如何从两个日期选择器对话框获取号码日间隔。 我有酒店登记的第一个日期选择器和酒店结账的第二个日期选择器对话框。我的问题是我希望从酒店结账和酒店登记入住。 这是我的两个日期选择器对话框......

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();
    }
 }

先谢谢你们!

0 个答案:

没有答案