I have two dates which the user should select: "From Date" and "To Date". The form should be updating such that the range of dates which the user can select for the "To Date" should consist of the week containing the "From Date".
For example, if the "From Date" is 23rd May then the "To Date" should be selected from 19, 20, 21, 22, 23, 24 or 25 of May and selecting dates out of that week should be impossible.
I am not able find the possible solution for this. Please help me to solve this.
Here is my code:
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy");
LocalDate now = new LocalDate(fromDate);
LocalDate monday = now.withDayOfWeek(DateTimeConstants.MONDAY);
System.out.printn(monday.toDate());
Using this code, I can get all the dates of that week and compare them, but I don't want to do it like this.