Advertisement
dwhitzzz

CheckOverLapsDates

Apr 6th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. /**
  2.  *  Assuming that date == null, means no end. For example endDate null, never end.
  3.  * @param newStartDate
  4.  * @param newEndDate
  5.  * @param startDate
  6.  * @param endDate
  7.  */
  8. public boolean checkOverLapsDates(Date newStartDate, Date newEndDate, Date startDate, Date endDate){
  9.     boolean canAdd = false;
  10.    
  11.     if ((newEndDate == null && endDate) == null)){
  12.         continue;
  13.     }
  14.  
  15.     //newStartDate shouldn't be between another existent date
  16.     if (Data.isCompresaTra(startDate, newStartDate,
  17.             endDate)) {
  18.         continue;
  19.     } else if (newEndDate != null
  20.             && Data.isCompresaTra(startDate, newEndDate,
  21.                     endDate)) {
  22.         //newEndDate shouldn't be between existent date
  23.         continue;
  24.     } else if (endDate != null
  25.             && Data.isCompresaTra(newStartDate, endDate,
  26.                     newEndDate)) {
  27.         //endDate shouldn't be between the newDates
  28.         continue;
  29.     } else {
  30.         canAdd = true;
  31.     }
  32.    
  33.     return canAdd;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement