DateRangePicker icon indicating copy to clipboard operation
DateRangePicker copied to clipboard

Disable future dates

Open EdinHas opened this issue 5 years ago • 1 comments

I need to disable all dates after today. If its 27th March I need to disable everything from 28th to the next 10 years. Is this possible?

Thanks.

EdinHas avatar Mar 27 '19 14:03 EdinHas

To disable future dates put 0 in nextYear calendar.

   final Calendar nextYear = Calendar.getInstance();
    nextYear.add(Calendar.YEAR, 0);

To disable past dates, you can set Year, Month, Day to 0.

    final Calendar lastYear = Calendar.getInstance();
    lastYear.add(Calendar.YEAR, 0);
    lastYear.add(Calendar.MONTH, 0);
    lastYear.add(Calendar.DAY_OF_MONTH, 0);

    ArrayList<Integer> list = new ArrayList<>();
    calendar.deactivateDates(list);

    ArrayList<Date> arrayList = new ArrayList<>();

    calendar.init(
            lastYear.getTime(),
            nextYear.getTime(),
            new Locale(LanguageCodes.ENGLISH))
            .inMode(CalendarPickerView.SelectionMode.RANGE)
            .withHighlightedDates(arrayList);

AleeeAhmed avatar Jun 20 '19 12:06 AleeeAhmed