List of usage examples for org.joda.time Days daysBetween
public static Days daysBetween(ReadablePartial start, ReadablePartial end)
Days
representing the number of whole days between the two specified partial datetimes. From source file:courtscheduler.domain.DateConstraint.java
License:Apache License
public int[] findDateRange(LocalDate sdate, LocalDate edate) { int dayCount = Days.daysBetween(sdate, edate).getDays(); //System.out.println(dayCount); int[] days = new int[dayCount + 1]; for (int i = 0; i <= dayCount; i++) { Integer day = findDate(sdate.plusDays(i)); if (day != null) { days[i] = day;//from ww w . j av a 2 s. c om } } return days; }
From source file:courtscheduler.domain.DateConstraint.java
License:Apache License
public Integer[] findDayOfWeek(int weekday) { LocalDate firstDay = info.getConferenceStartDate().withDayOfWeek(weekday); ArrayList<Integer> days = new ArrayList<Integer>(); if (firstDay.isBefore(info.getConferenceStartDate())) { firstDay.plusWeeks(1);/*from w w w. ja v a 2 s .co m*/ } while (firstDay.isBefore(info.getConferenceEndDate()) || firstDay.equals(info.getConferenceEndDate())) { Integer index = Days.daysBetween(info.getConferenceStartDate(), firstDay).getDays(); if (index >= 0) { days.add(index); } firstDay = firstDay.plusWeeks(1); } return days.toArray(new Integer[days.size()]); }
From source file:courtscheduler.persistence.CourtScheduleInfo.java
License:Apache License
public int getNumberOfConferenceDays() { return Days.daysBetween(conferenceStartDate, conferenceEndDate).getDays(); }
From source file:cz.krtinec.birthday.dto.Event.java
License:Open Source License
public Event(String displayName, long contactId, LocalDate eventDate, String lookupKey, DateIntegrity integrity, long rawContactId) { this.integrity = integrity; this.displayName = displayName; this.contactId = contactId; this.lookupKey = lookupKey; this.eventDate = eventDate; if (this.eventDate != null) { eventDaySort = SHORT_FORMAT.print(this.eventDate); } else {/*from www .j av a 2s .com*/ eventDaySort = "0000"; } nextYear = eventDaySort.compareTo(pivot) < 0; if (this.eventDate != null) { int year = nextYear ? today.getYear() + 1 : today.getYear(); LocalDate tempCalendar; try { tempCalendar = new LocalDate(year, eventDate.getMonthOfYear(), eventDate.getDayOfMonth()); } catch (IllegalFieldValueException e) { //Probably February 29th tempCalendar = new LocalDate(year, eventDate.getMonthOfYear(), eventDate.getDayOfMonth() - 1); } daysToEvent = Days.daysBetween(today, tempCalendar).getDays(); } this.rawContactId = rawContactId; }
From source file:damo.three.ie.prepayusage.BasicUsageItemsGrouped.java
License:Open Source License
/** * Add some meta-data to the usage groups. *//*from w ww . j a v a2 s. com*/ private void updateGroupName() { long date = basicUsageItems.get(0).getExpireDate(); if (date == DateUtils.WONT_EXPIRE) { expireGroup = "Won't expire"; expireGroupType = ExpireGroupType.GOOD; groupDateTime = new DateTime(DateUtils.WONT_EXPIRE); } else if (date == DateUtils.QUEUED) { expireGroup = "Queued"; expireGroupType = ExpireGroupType.GOOD; groupDateTime = new DateTime(DateUtils.QUEUED); } else { // Falling down this far.. must be a date so! groupDateTime = new DateTime(date); int daysRemaining = Days.daysBetween(dateTimeNow.withTimeAtStartOfDay(), getAbsoluteExpireyDateTime()) .getDays() - 1; if (daysRemaining > 5) { expireGroupType = ExpireGroupType.GOOD; } else if (daysRemaining >= 3 && daysRemaining <= 5) { expireGroupType = ExpireGroupType.WARNING; } else { expireGroupType = ExpireGroupType.BAD; } expireGroup = "Expires: " + DateUtils.formatDate(date); expireGroup += " (" + new PrettyTime().format(getAbsoluteExpireyDateTime().toDate()) + ")"; } }
From source file:DAO.AlertasDAO.java
private int calcularDias(String fecha) { return Days.daysBetween(new DateTime().now(), new DateTime(fecha)).getDays(); }
From source file:dbchubreast_web.service.updater.UpdaterSurvival.java
License:Open Source License
/** ============================================================================= */ public Double calculateSurvival(Date dateStart, Date dateEnd) { if (dateStart == null || dateEnd == null) { return null; }// w w w .ja v a2 s .c o m Double daysInAMonth = 365.24 / 12; DateTime startDate = new DateTime(dateStart); DateTime endDate = new DateTime(dateEnd); int days = Days.daysBetween(startDate, endDate).getDays(); // int months = Months.monthsBetween(startDate, endDate).getMonths(); // int years = Years.yearsBetween(startDate, endDate).getYears(); Double survival = days / daysInAMonth; survival = Math.round(survival * 100d) / 100d; // System.out.println("years=" + years + ", months=" + months + ", // days=" + days + "\t" + "survival=" + survival); return survival; }
From source file:dbchubreast_web.service.util.FormatService.java
License:Open Source License
/** ====================================================================================== */ public Integer getPeriodInDays(Date dateBegin, Date dateEnd) { DateTime begin = new DateTime(dateBegin); DateTime end = new DateTime(dateEnd); if (begin != null && end != null) { return Days.daysBetween(begin, end).getDays(); }//from ww w.j a v a 2 s . c om return null; }
From source file:de.dekstop.cosm.Coverage.java
License:Open Source License
static int getDistance(CoverageType type, DateTime start, DateTime end) { switch (type) { case SECOND:/*from w w w. j a v a2s .c o m*/ return Seconds.secondsBetween(start, end).getSeconds(); case MINUTE: return Minutes.minutesBetween(start, end).getMinutes(); case HOUR: return Hours.hoursBetween(start, end).getHours(); case DAY: return Days.daysBetween(start, end).getDays(); } throw new IllegalArgumentException("Unknown type: " + type); }
From source file:de.iteratec.iteraplan.businesslogic.reports.staticquery.consistency.CheckProjectsUnsynchronizedWithAssociatedInformationSystemReleases.java
License:Open Source License
public Result executeCheck(Map<String, Parameter> parameters) { if (!parameters.containsKey(DAYS_PARAMETER)) { throw new IllegalArgumentException("A consistency check parameter is not available."); }/*from ww w . j av a2 s. com*/ /* Get the object for the parameter named 'days'. */ Parameter parameter = parameters.get(DAYS_PARAMETER); /* Get the value of the parameter. */ int days = Integer.parseInt(parameter.getValue()); List<Object[]> listObjects = getConsistencyCheckDAO() .getUnsynchronizedProjectsWithInformationSystemReleases(); for (Object[] objects : listObjects) { Project p = (Project) objects[0]; Date projectEndDate = p.runtimeEndsAt(); DateTime projectEndDateTime = new LocalDate(projectEndDate).toDateTimeAtStartOfDay(); InformationSystemRelease release = (InformationSystemRelease) objects[1]; Date releaseStartDate = release.runtimeStartsAt(); DateTime releaseStartDateTime = new LocalDate(releaseStartDate).toDateTimeAtStartOfDay(); /* when the startDate or endDate is not set, skip this ISR/Proj */ if (releaseStartDate == null || projectEndDate == null) { continue; } int gapDays = Days.daysBetween(releaseStartDateTime, projectEndDateTime).getDays(); /** * if the day-param is positive, we are looking for ISR that start at least x days before the * ProjEnd */ if (days >= 0) { if (gapDays >= days) { addToResult(p, release); } } /** * if the day-param is negative, we are looking for ISR that start at least x days after the * ProjEnd */ else { if (gapDays <= days) { addToResult(p, release); } } } return getResult(); }