Materialdatepicker Shows Current Date Instead Of Needed
Using MaterialDatePicker I want to show required date and give an opportunity to select another. But when a DatePicker appears it shows current date instead of specified. I plug th
Solution 1:
You can set the month to which the picker opens with the method constraintsBuilder.setOpenAt()
.
The default value is the current month if within the bounds otherwise the earliest month within the bounds:
CalendarConstraints.BuilderconstraintsBuilder=newCalendarConstraints.Builder();
LocalDateTimelocal= LocalDateTime.of(2020, 11, 1, 0, 0);
long openAt= local.atZone(ZoneId.ofOffset("UTC", ZoneOffset.UTC)).toInstant().toEpochMilli();
//you can also use Calendar.getInstance()...
constraintsBuilder.setOpenAt(openAt);
builder.setCalendarConstraints(constraintsBuilder.build());
You can set a default selection (defaults to no selection) with:
builder.setSelection(....);
Post a Comment for "Materialdatepicker Shows Current Date Instead Of Needed"