Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Restrict start date and time range with popupdateField
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();
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:
startDate - - the allowed range's start date
Thanks for the reply,
Yes I have set the date resolution to popupDate filed like
but it is taking the past time. like my system time is 11:12.
My date is as folows : "Mon Nov 14 11:12:28 IST 2016"
I have seleted the time as 9:00. from popupdate field, it is allowing the past time even if we have the include time.
do we have any solution?
With some research I found similar bug being reported already before. Please check this, and confirm if it is the same issue.