List of usage examples for org.joda.time LocalDate isAfter
public boolean isAfter(ReadablePartial partial)
From source file:hudson.plugins.codecover.portlet.CodeCoverLoadData.java
License:Open Source License
/** * Get CodeCover coverage results of all jobs and store into a sorted * HashMap by date./* w w w .j ava 2s. c o m*/ * * @param jobs * jobs of Dashboard view * @param daysNumber * number of days * @return Map The sorted summaries */ public static Map<LocalDate, CodeCoverCoverageResultSummary> loadChartDataWithinRange(List<Job> jobs, int daysNumber) { Map<LocalDate, CodeCoverCoverageResultSummary> summaries = new HashMap<LocalDate, CodeCoverCoverageResultSummary>(); // Get the last build (last date) of the all jobs LocalDate lastDate = Utils.getLastDate(jobs); // No builds if (lastDate == null) { return null; } // Get the first date from last build date minus number of days LocalDate firstDate = lastDate.minusDays(daysNumber); // For each job, get CodeCover coverage results according with // date range (last build date minus number of days) for (Job job : jobs) { Run run = job.getLastBuild(); if (null != run) { LocalDate runDate = new LocalDate(run.getTimestamp()); while (runDate.isAfter(firstDate)) { summarize(summaries, run, runDate, job); run = run.getPreviousBuild(); if (null == run) { break; } runDate = new LocalDate(run.getTimestamp()); } } } // Sorting by date, ascending order Map<LocalDate, CodeCoverCoverageResultSummary> sortedSummaries = new TreeMap(summaries); return sortedSummaries; }
From source file:hudson.plugins.codecover.portlet.utils.Utils.java
License:Open Source License
/** * For the given list of jobs, this will search all jobs and return * the last run date of all./*from w ww . ja v a 2s. co m*/ * * @param jobs * a list of jobs from the DashBoard Portlet view * @return LocalDate the last date of all jobs that belogs to * Dashboard View. */ public static LocalDate getLastDate(List<Job> jobs) { LocalDate lastDate = null; for (Job job : jobs) { Run lastRun = job.getLastBuild(); if (lastRun != null) { LocalDate date = new LocalDate(lastRun.getTimestamp()); if (lastDate == null) { lastDate = date; } if (date.isAfter(lastDate)) { lastDate = date; } } } return lastDate; }
From source file:hudson.plugins.emma.portlet.EmmaLoadData.java
License:Open Source License
/** * Get Emma coverage results of all jobs and store into a sorted * HashMap by date.// w w w. j a v a2 s .co m * * @param jobs * jobs of Dashboard view * @param daysNumber * number of days * @return Map The sorted summaries */ public static Map<LocalDate, EmmaCoverageResultSummary> loadChartDataWithinRange(List<Job> jobs, int daysNumber) { Map<LocalDate, EmmaCoverageResultSummary> summaries = new HashMap<LocalDate, EmmaCoverageResultSummary>(); // Get the last build (last date) of the all jobs LocalDate lastDate = Utils.getLastDate(jobs); // No builds if (lastDate == null) { return null; } // Get the first date from last build date minus number of days LocalDate firstDate = lastDate.minusDays(daysNumber); // For each job, get Emma coverage results according with // date range (last build date minus number of days) for (Job job : jobs) { Run run = job.getLastBuild(); if (null != run) { LocalDate runDate = new LocalDate(run.getTimestamp()); while (runDate.isAfter(firstDate)) { summarize(summaries, run, runDate, job); run = run.getPreviousBuild(); if (null == run) { break; } runDate = new LocalDate(run.getTimestamp()); } } } // Sorting by date, ascending order Map<LocalDate, EmmaCoverageResultSummary> sortedSummaries = new TreeMap(summaries); return sortedSummaries; }
From source file:hudson.plugins.jacoco.portlet.JacocoLoadData.java
License:Open Source License
/** * Get JaCoCo coverage results of all jobs and store into a sorted * HashMap by date./*from w w w .j a v a2s. c o m*/ * * @param jobs * jobs of Dashboard view * @param daysNumber * number of days * @return Map The sorted summaries */ public static Map<LocalDate, JacocoCoverageResultSummary> loadChartDataWithinRange(List<Job> jobs, int daysNumber) { Map<LocalDate, JacocoCoverageResultSummary> summaries = new HashMap<LocalDate, JacocoCoverageResultSummary>(); // Get the last build (last date) of the all jobs LocalDate lastDate = Utils.getLastDate(jobs); // No builds if (lastDate == null) { return null; } // Get the first date from last build date minus number of days LocalDate firstDate = lastDate.minusDays(daysNumber); // For each job, get JaCoCo coverage results according with // date range (last build date minus number of days) for (Job job : jobs) { Run run = job.getLastBuild(); if (null != run) { LocalDate runDate = new LocalDate(run.getTimestamp()); while (runDate.isAfter(firstDate)) { summarize(summaries, run, runDate, job); run = run.getPreviousBuild(); if (null == run) { break; } runDate = new LocalDate(run.getTimestamp()); } } } // Sorting by date, ascending order Map<LocalDate, JacocoCoverageResultSummary> sortedSummaries = new TreeMap<LocalDate, JacocoCoverageResultSummary>( summaries); return sortedSummaries; }
From source file:hudson.plugins.karma.portlet.KarmaLoadData.java
License:Open Source License
/** * Get Karma coverage results of all jobs and store into a sorted * HashMap by date.// w w w .j a v a 2 s .c o m * * @param jobs * jobs of Dashboard view * @param daysNumber * number of days * @return Map The sorted summaries */ public static Map<LocalDate, KarmaCoverageResultSummary> loadChartDataWithinRange(List<Job> jobs, int daysNumber) { Map<LocalDate, KarmaCoverageResultSummary> summaries = new HashMap<LocalDate, KarmaCoverageResultSummary>(); // Get the last build (last date) of the all jobs LocalDate lastDate = Utils.getLastDate(jobs); // No builds if (lastDate == null) { return null; } // Get the first date from last build date minus number of days LocalDate firstDate = lastDate.minusDays(daysNumber); // For each job, get Karma coverage results according with // date range (last build date minus number of days) for (Job job : jobs) { Run run = job.getLastBuild(); if (null != run) { LocalDate runDate = new LocalDate(run.getTimestamp()); while (runDate.isAfter(firstDate)) { summarize(summaries, run, runDate, job); run = run.getPreviousBuild(); if (null == run) { break; } runDate = new LocalDate(run.getTimestamp()); } } } // Sorting by date, ascending order Map<LocalDate, KarmaCoverageResultSummary> sortedSummaries = new TreeMap(summaries); return sortedSummaries; }
From source file:managers.Config.java
/** * No of Days Exceeded calculator. Then Fine = chargePerDay * return value of this method. * @param returnDateAttribute//from ww w .ja v a2 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;//from w w w. ja va 2 s . c o m } // 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/*from www. j a va2s.com*/ * @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
protected void checkDates(final Party parent, final LocalDate begin, final LocalDate end) { if (begin != null && end != null && begin.isAfter(end)) { throw new OrganizationDomainException("error.Accountability.begin.is.after.end"); }/* ww w . ja va2 s . c om*/ checkBeginFromOldestParentAccountability(parent, begin); }
From source file:module.organization.domain.Accountability.java
License:Open Source License
public boolean contains(final LocalDate begin, final LocalDate end) { check(begin, "error.Accountability.intercepts.invalid.begin"); return (end == null || !getBeginDate().isAfter(end)) && (!hasEndDate() || !begin.isAfter(getEndDate())); }