title: Date Picker Validation in android studio
body: <p>when today date is between 1-15 than previous month 16-31 date enabled.
  when today date is between 16-31 than current month 1-15 date enabled. My Code is please resolve my problem:</p>
  
  <pre><code> 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 day, int month, int year) {
                  cal = Calendar.getInstance();
                  cal.setTimeInMillis(System.currentTimeMillis());
                  //int curyear = cal.get(Calendar.YEAR);
                  cal.set(day, month, year);
  
              }
          }, day, month, year);
          if ((day &lt; 15)) {
              int month=cal.get(Calendar.MONTH);
              Log.e("Month", String.valueOf(month));
              int days = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
              Log.e("days", String.valueOf(days));
              int lastday = days-day;
              Log.e("Lastday", String.valueOf(lastday));
              dpDialog.getDatePicker().setMinDate((month-1)+System.currentTimeMillis()-(1000 * 60 * 60 * 24*(days-day)));
              long now = System.currentTimeMillis() - 1000;
  //        dp_time.setMinDate(now);
              dpDialog.getDatePicker().setMaxDate((month-1)+now +(1000 * 60 * 60 * 24 *15));
  
  
          }
          else if ((day &gt; 15)) {
              int days = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
              Log.e("days", String.valueOf(days));
              int lastday = days - 15;
              Log.e("lastday", String.valueOf(lastday));
              int month=cal.get(Calendar.MONTH);
              Log.e("Month", String.valueOf(month));
              dpDialog.getDatePicker().setMinDate((1000*60*60*24*(day+1)));
              long now = System.currentTimeMillis() - 1000;
  //        dp_time.setMinDate(now);
              dpDialog.getDatePicker().setMaxDate(now +(1000 * 60 * 60 * 24 *lastday));
          }
          dpDialog.show();
  </code></pre>