Advertisement
BoberDiversant

Untitled

Apr 21st, 2019
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1.     public static boolean isSelectedTimeWithinIntervals(LocalTime selectedTime, List<Interval> intervals) {
  2.         boolean result = false;
  3.         for (Interval interval : intervals) {
  4.             long begin = parseStringLdtToLdt(interval.getDateBegin()).toEpochSecond(ZoneOffset.UTC);
  5.             long end = parseStringLdtToLdt(interval.getDateEnd()).toEpochSecond(ZoneOffset.UTC);
  6.  
  7.             LocalDate selectedDate = parseStringLdtToLdt(interval.getDateBegin()).toLocalDate();
  8.             LocalDateTime selectedDateTime = LocalDateTime.of(selectedDate, selectedTime);
  9.             long selected = selectedDateTime.toEpochSecond(ZoneOffset.UTC);
  10.  
  11.             if (begin <= selected && selected <= end) {
  12.                 result = true;
  13.                 break;
  14.             }
  15.         }
  16.         return result;
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement