List of usage examples for org.joda.time LocalDate isBefore
public boolean isBefore(ReadablePartial partial)
From source file:info.matchingservice.dom.Profile.ProfileElementTimePeriod.java
License:Apache License
public String validateUpdateTimePeriod(LocalDate startDate, LocalDate endDate, Integer weight) { final LocalDate today = LocalDate.now(); if (endDate != null && endDate.isBefore(today)) { return "ENDDATE_BEFORE_TODAY"; }// ww w .j av a 2 s .c o m if (endDate != null && startDate != null && endDate.isBefore(startDate) ) { return "ENDDATE_BEFORE_STARTDATE"; } return null; }
From source file:julian.lylly.model.Prospect.java
public boolean isActive() { LocalDate now = LocalDate.now(); return !now.isBefore(start) && now.isBefore(end); }
From source file:julian.lylly.model.Prospect.java
public List<Pair<Duration, Duration>> getBudgets(LocalDate pointer, Duration timespent) { int relDay = Days.daysBetween(start, pointer).getDays(); if (pointer.isBefore(start) || !end.isAfter(pointer)) { throw new IllegalArgumentException("day is out of range:\t" + "start = " + start.toString() + "\t" + "pointer = " + pointer.toString() + "\t" + "end = " + end.toString()); }//from w w w. j a v a2 s. c o m List<Integer> subl = weights.subList(relDay, weights.size()); int sum = 0; for (int k : subl) { sum += k; } Duration minleft = Util.max(Duration.ZERO, min.minus(timespent)); Duration maxleft = Util.max(Duration.ZERO, max.minus(timespent)); List<Pair<Duration, Duration>> res = new ArrayList<>(); for (int k : subl) { Duration bMin = minleft.multipliedBy(k).dividedBy(sum); Duration bMax = maxleft.multipliedBy(k).dividedBy(sum); res.add(new Pair(bMin, bMax)); } return res; }
From source file:julian.lylly.model.Prospect.java
static void checkStartEndConstraint(LocalDate start, LocalDate end) { if (!start.isBefore(end)) { throw new IllegalArgumentException("start must be less than end"); }/* ww w. java 2 s . c om*/ }
From source file:managers.Config.java
/** * No of Days Exceeded calculator. Then Fine = chargePerDay * return value of this method. * @param returnDateAttribute/*from ww w . j a va 2 s . c o m*/ * @param dueDateAttribute * @return int days exceeded */ public static int daysExceeded(String returnDateAttribute, String dueDateAttribute) { int daysExceeded = 0; dueDateAttribute = changeDateFormat(dueDateAttribute); // DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); // LocalDate dueDateFormatted = new LocalDate(dueDateAttribute); // dueDateAttribute = format.format(dueDateFormatted); System.out.println("Due Date :" + dueDateAttribute.toString()); LocalDate dueDate = new LocalDate(dueDateAttribute); // java.util.Date returnDateFormatted = new java.util.Date(returnDateAttribute); // returnDateAttribute = format.format(returnDateFormatted); if (returnDateAttribute == null && dueDate.isAfter(new LocalDate(new java.util.Date()))) //book not returned and days not exceeded { daysExceeded = 0; System.out.println("book not returned and days not exceeded"); } else if (returnDateAttribute == null && dueDate.isBefore(new LocalDate(new java.util.Date()))) // book not returned and days exceeded { daysExceeded = Days.daysBetween(dueDate, new LocalDate(new java.util.Date())).getDays(); System.out.println("book not returned anddays not exceeded"); } else //book is returned { returnDateAttribute = changeDateFormat(returnDateAttribute); LocalDate returnDate = new LocalDate(returnDateAttribute); if (dueDate.isAfter(returnDate)) //book retuned and days not exceeded { daysExceeded = 0; System.out.println("book returned and days not exceeded"); } else { System.out.println("book returned and days exceeded"); daysExceeded = Days.daysBetween(dueDate, returnDate).getDays(); // book returned and days exceeded } } return daysExceeded; }
From source file:me.vertretungsplan.parser.LegionBoardParser.java
License:Mozilla Public License
void parseLegionBoard(SubstitutionSchedule substitutionSchedule, JSONArray changes, JSONArray courses, JSONArray teachers) throws IOException, JSONException { if (changes == null) { return;/* w w w. j a v a 2 s .c om*/ } // Link course IDs to their names HashMap<String, String> coursesHashMap = null; if (courses != null) { coursesHashMap = new HashMap<>(); for (int i = 0; i < courses.length(); i++) { JSONObject course = courses.getJSONObject(i); coursesHashMap.put(course.getString("id"), course.getString("name")); } } // Link teacher IDs to their names HashMap<String, String> teachersHashMap = null; if (teachers != null) { teachersHashMap = new HashMap<>(); for (int i = 0; i < teachers.length(); i++) { JSONObject teacher = teachers.getJSONObject(i); teachersHashMap.put(teacher.getString("id"), teacher.getString("name")); } } // Add changes to SubstitutionSchedule LocalDate currentDate = LocalDate.now(); SubstitutionScheduleDay substitutionScheduleDay = new SubstitutionScheduleDay(); substitutionScheduleDay.setDate(currentDate); for (int i = 0; i < changes.length(); i++) { final JSONObject change = changes.getJSONObject(i); final Substitution substitution = getSubstitution(change, coursesHashMap, teachersHashMap); final LocalDate startingDate = new LocalDate(change.getString("startingDate")); final LocalDate endingDate = new LocalDate(change.getString("endingDate")); // Handle multi-day changes if (!startingDate.isEqual(endingDate)) { if (!substitutionScheduleDay.getSubstitutions().isEmpty()) { substitutionSchedule.addDay(substitutionScheduleDay); } for (int k = 0; k < 8; k++) { final LocalDate date = LocalDate.now().plusDays(k); if ((date.isAfter(startingDate) || date.isEqual(startingDate)) && (date.isBefore(endingDate) || date.isEqual(endingDate))) { substitutionScheduleDay = new SubstitutionScheduleDay(); substitutionScheduleDay.setDate(date); substitutionScheduleDay.addSubstitution(substitution); substitutionSchedule.addDay(substitutionScheduleDay); currentDate = date; } } continue; } // If starting date of change does not equal date of SubstitutionScheduleDay if (!startingDate.isEqual(currentDate)) { if (!substitutionScheduleDay.getSubstitutions().isEmpty()) { substitutionSchedule.addDay(substitutionScheduleDay); } substitutionScheduleDay = new SubstitutionScheduleDay(); substitutionScheduleDay.setDate(startingDate); currentDate = startingDate; } substitutionScheduleDay.addSubstitution(substitution); } substitutionSchedule.addDay(substitutionScheduleDay); }
From source file:me.vertretungsplan.parser.WebUntisParser.java
License:Mozilla Public License
/** * find out if there's a holiday currently and if so, also display substitutions after it * * @return/* www . j a va 2 s. c om*/ * @throws JSONException * @throws CredentialInvalidException * @throws IOException */ private int getDaysToAdd() throws JSONException, CredentialInvalidException, IOException { final LocalDate today = LocalDate.now(); int daysToAdd = 0; try { // JSONArray holidays = getHolidays(); for (int i = 0; i < holidays.length(); i++) { LocalDate startDate = DATE_FORMAT .parseLocalDate(String.valueOf(holidays.getJSONObject(i).getInt("startDate"))); LocalDate endDate = DATE_FORMAT .parseLocalDate(String.valueOf(holidays.getJSONObject(i).getInt("endDate"))); if (!startDate.isAfter(today.plusDays(6)) && !endDate.isBefore(today)) { if (startDate.isBefore(today)) { daysToAdd += Days.daysBetween(today, endDate).getDays() + 1; } else { daysToAdd += Days.daysBetween(startDate, endDate).getDays() + 2; } } } } catch (UnauthorizedException ignored) { } return daysToAdd; }
From source file:module.organization.domain.Accountability.java
License:Open Source License
private void checkBeginFromOldestParentAccountability(final Party parent, final LocalDate begin) throws DomainException { Accountability oldest = null;/*from w w w.ja v a2 s .co m*/ for (final Accountability accountability : parent.getParentAccountabilitiesSet()) { if (oldest == null || accountability.getBeginDate().isBefore(oldest.getBeginDate())) { oldest = accountability; } } if (oldest != null && begin.isBefore(oldest.getBeginDate())) { final String[] args = new String[] { oldest.getChild().getPartyName().getContent(), oldest.getBeginDate().toString("dd/MM/yyyy") }; throw new OrganizationDomainException("error.Accountability.begin.starts.before.oldest.parent.begin", args); } }
From source file:module.organization.domain.Accountability.java
License:Open Source License
/** * /*from w w w.j a v a2 s . c o m*/ * @param localDate1 localDate1 * @param localDate2 localDate2 * @return false if any of the dates are null, or if localDate1 isn't after * localDate2, true otherwise */ private static boolean isAfter(final LocalDate localDate1, final LocalDate localDate2) { return localDate1 != null && localDate2 != null && localDate2.isBefore(localDate1); }
From source file:module.organization.domain.Party.java
License:Open Source License
/** * //from ww w .j a v a 2 s .c om * @param child child * @param type type * @param begin begin * @param end end * @param justification an information justification/reason for the change of accountability, or null if there is none, or * none is provided * @return Accountability */ @Atomic public Accountability addChild(final Party child, final AccountabilityType type, final LocalDate begin, final LocalDate end, String justification) { Accountability intersectingAccountability = getIntersectingChildAccountability(child, type, begin, end); if (intersectingAccountability != null) { if (begin == null || (begin != null && intersectingAccountability.getBeginDate() != null && begin.isBefore(intersectingAccountability.getBeginDate()))) { intersectingAccountability.setBeginDate(begin); } if (end == null || (end != null && intersectingAccountability.getEndDate() != null && end.isAfter(intersectingAccountability.getEndDate()))) { intersectingAccountability.editDates(intersectingAccountability.getBeginDate(), end); } return intersectingAccountability; } return Accountability.create(this, child, type, begin, end, justification); }