Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean isSelectedTimeWithinIntervals(LocalTime selectedTime, List<Interval> intervals) {
- boolean result = false;
- for (Interval interval : intervals) {
- long begin = parseStringLdtToLdt(interval.getDateBegin()).toEpochSecond(ZoneOffset.UTC);
- long end = parseStringLdtToLdt(interval.getDateEnd()).toEpochSecond(ZoneOffset.UTC);
- LocalDate selectedDate = parseStringLdtToLdt(interval.getDateBegin()).toLocalDate();
- LocalDateTime selectedDateTime = LocalDateTime.of(selectedDate, selectedTime);
- long selected = selectedDateTime.toEpochSecond(ZoneOffset.UTC);
- if (begin <= selected && selected <= end) {
- result = true;
- break;
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement