Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a custom minimum and maximum date selection day in "wdullaer materialdatetimepicker"

I am working on a project where I need to restrict the user from choosing any other dates than I want.

by reading some articles and SO post i tried the following which is supposed to work

    com.wdullaer.materialdatetimepicker.date.DatePickerDialog dpd = newInstance(
                ActivityClaimOffers.this,
                now.get(Calendar.YEAR),
                now.get(Calendar.MONTH),
                now.get(Calendar.DAY_OF_MONTH)
        );
    dpd.setMinDate(calendar);
    dpd.setMaxDate(calendar);

but I could not figure out how to pass custom dates as calendar objects. as both setMinDate() and setMaxDate() takes Calendar as parameter

like image 544
Nilabja Avatar asked May 31 '16 08:05

Nilabja


1 Answers

Like this :

Calendar calendar = new GregorianCalendar(year, monthOfYear, dayOfMonth);

and for your code:

dpd.setMinDate(new GregorianCalendar(2000, 5, 23));
like image 116
Rucsi Avatar answered Oct 18 '22 09:10

Rucsi