I am trying to resrict the popup date field to now allow the past date and time from current time.
date picker should only allow the date future dates.
I have used setRangeStart method. it ia allowing the dates as we specified.
problem: I would also like to restrict the time (hours and minutes) to not to allow the past time.
for instance now the currect time is 12:00, my date picker should only allow the drop down to pick after 12:00, i would want to disable the 1 :00 to 11:00.
like the sane way the minutes dropdown also.
does vaadin has this feature? could you suggest me on this how i could implement.
here is my pice of code.
PopupDateField popupDateField= new PopupDateField();
popupDateField.setDateFormat(“dd/MM/yyyy HH:mm”);
popupDateField.setRangeStart(currentDate);
popupDateField.setResolution(PopupDateField.RESOLUTION_HOUR);
popupDateField.setResolution(PopupDateField.RESOLUTION_MIN);
java.util.Calendar calendar = java.util.Calendar.getInstance();
Date currentDate = new Date(calendar.getTimeInMillis());
The API spec says the following, which at least by my interpretation says that if your datefield resolution is set to include time, it should be taken in the account in the validation too. If it really is not doing it, there is bug somewhere.
public void setRangeStart(Date startDate)
Sets the start range for this component. If the value is set before this date (taking the resolution into account), the component will not validate. If startDate is set to null, any value before endDate will be accepted by the rangeParameters: