I have created a TimePicker on Java. I have achieved to veto a range time (12h to 23.30h). But I want to make two different ranges of availables times, for example (12h to 15h and 19h to 23h). I have this Override created for achieving to create one range of times available:
public class SampleTimeVetoPolicy implements TimeVetoPolicy {
@Override
public boolean isTimeAllowed(LocalTime time) {
return PickerUtilities.isLocalTimeInRange(time,LocalTime.of(12,00),LocalTime.of(23,30),true);
}
}
I don't know how to make this two different ranges.
Example of what I execute with the actual override:
Thanks everyone! (The lib used is lgooddatepicker)
The "simplest" solution might be to do something like...
return PickerUtilities.isLocalTimeInRange(...) || PickerUtilities.isLocalTimeInRange(...);
A more robust solution would be to create a TimeRange
class (taking a start and end time of the range) which has a contains
style method and build a List
of them and simply loop over the list until either you complete the loop or one returns false