0

I am doing one application in that i want to disable today date if time is after 10AM. I am giving one condition, in that i am getting the next date if time is after 10Am but in calendar today date not disabling. It showing today date, if i am selcting that date then its setting tomorrow date in my edit Text. How to disable the date if time is after 10Am.This is my code.

dialog = new DatePickerDialog(ProductDetails.this,new DatePickerDialog.OnDateSetListener() {

                            @Override
                                public void onDateSet(DatePicker view, int year,
                                                      int monthOfYear, int dayOfMonth) {
                                    // Display Selected date in textbox
                                    datestr = dayOfMonth + "-"
                                            + (monthOfYear + 1) + "-" + year;
                                /*datestr = year + "-"
                                        + (monthOfYear + 1) + "-" + dayOfMonth;*/
                                    System.out.println("Datestr is--" + datestr);

                                    date_edit_txt.setText(datestr);

                                    if(value>10){
                                        mDay=mDay+1;
                                        view.updateDate(mYear,mMonth,mDay);
                                        dialog.getDatePicker().setMinDate(mDay);

                                        Log.e("time is >10..","after 10..");

                                    }


                                }

                            }, mDay, mMonth, mYear);



                    dialog.getDatePicker().setMinDate(c.getTimeInMillis());
                    dialog.show();
                }
Yaseen Ahmad
  • 1,807
  • 5
  • 25
  • 43
Yamuna
  • 157
  • 2
  • 15
  • This is the pure wrong code for your requirement ! – Piyush Aug 02 '16 at 05:44
  • oh? Then how can i acheive my requirement. Now i have only one issue, that is setting the date as next day if time is afetr 10Am – Yamuna Aug 02 '16 at 05:46
  • 1
    Check [this](http://stackoverflow.com/questions/6537535/check-date-with-todays-date) – Piyush Aug 02 '16 at 05:47
  • if(value>10){ mDay=mDay+1; c.set(Calendar.YEAR, mYear); c.set(Calendar.MONTH, mMonth); c.set(Calendar.DAY_OF_MONTH, mDay); view.updateDate(mYear,mMonth,mDay); dialog.getDatePicker().setMinDate(mDay); } previously i agve like this, but its not working – Yamuna Aug 02 '16 at 06:01

0 Answers0