MaterialDateTimePicker icon indicating copy to clipboard operation
MaterialDateTimePicker copied to clipboard

Disable recurrent days.

Open cristiandaulisio opened this issue 4 years ago • 1 comments

Hello, is it possible disable (for example) all saturday of each month and year? or disable 25 dicember of each year? etc.

cristiandaulisio avatar Nov 18 '20 17:11 cristiandaulisio

First get a list with your required dates - "holidaydata". You can use do while loop to get the Saturdays and Sundays for the given time period and add along with your other holdiays to this list.

Using setDisabledDays(disbledDays) you can disable these days.

SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); java.util.Date date = null; for (String holidaydatum : holidaydata) { try { date = sdf.parse(holidaydatum); } catch (ParseException | java.text.ParseException e) { e.printStackTrace(); } calendar = dateToCalendar(date); List<Calendar> dates = new ArrayList<>(); dates.add(calendar); Calendar[] disbledDays = dates.toArray(new Calendar[dates.size()]); dpd.setDisabledDays(disbledDays); }

nadiminti avatar Jul 05 '22 07:07 nadiminti