I would like to implement the following behaviour:
- When today's date is less than 15,1-15date is enabled in date Picker
- When today's date is greater than 15,16-31date is enabled in date picker
My code is:
private void DateDialog() {
    final DatePickerDialog dpDialog = new DatePickerDialog(this,android.app.AlertDialog.THEME_DEVICE_DEFAULT_DARK,new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
            cal = Calendar.getInstance();
            cal.setTimeInMillis(System.currentTimeMillis());
            //int curyear = cal.get(Calendar.YEAR);
            cal.set(i, i1, i2);
            etsubmstartdate.setText(dateformatter.format(cal.getTime()));
            selecteddate = dateformatter.format(cal.getTime());
            Log.e("Date of first edit text",selecteddate);
            etsubmstartdate.setText(selecteddate);
        }
    }, year, month, day);
    if (System.currentTimeMillis()<=15)
    {
        dpDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
        long now = System.currentTimeMillis() - 1000;
        dpDialog.getDatePicker().setMaxDate(now+(1000*60*60*24*15));
        dpDialog.show();
    }
    else if(System.currentTimeMillis()>=15)
    {
        dpDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000*60*60*24*2);
        long now = System.currentTimeMillis() - 1000*60*60*24*2;
        dpDialog.getDatePicker().setMaxDate(now+(1000*60*60*24*14));
        dpDialog.show();
    }
}
 
     
     
    