List of usage examples for org.joda.time LocalDate compareTo
public int compareTo(ReadablePartial partial)
From source file:cherry.foundation.bizcal.BizYearUtil.java
License:Apache License
public static Range<LocalDate> between(LocalDate from, LocalDate to) { return Range.between(from, to, new Comparator<LocalDate>() { @Override/* w w w. java 2 s . c o m*/ public int compare(LocalDate o1, LocalDate o2) { return o1.compareTo(o2); } }); }
From source file:cherry.foundation.validator.JodaTimeMaxValidator.java
License:Apache License
@Override public boolean isValid(ReadablePartial value, ConstraintValidatorContext context) { if (value == null) { return true; } else if (value instanceof LocalDate) { LocalDate max = LocalDate.parse(maxValue); if (inclusive) { return max.compareTo(value) >= 0; } else {/*from w w w .ja v a 2 s . c om*/ return max.compareTo(value) > 0; } } else if (value instanceof LocalDateTime) { LocalDateTime max = LocalDateTime.parse(maxValue); if (inclusive) { return max.compareTo(value) >= 0; } else { return max.compareTo(value) > 0; } } else { return true; } }
From source file:cherry.foundation.validator.JodaTimeMinValidator.java
License:Apache License
@Override public boolean isValid(ReadablePartial value, ConstraintValidatorContext context) { if (value == null) { return true; } else if (value instanceof LocalDate) { LocalDate min = LocalDate.parse(minValue); if (inclusive) { return min.compareTo(value) <= 0; } else {//from ww w . j av a2 s . c o m return min.compareTo(value) < 0; } } else if (value instanceof LocalDateTime) { LocalDateTime min = LocalDateTime.parse(minValue); if (inclusive) { return min.compareTo(value) <= 0; } else { return min.compareTo(value) < 0; } } else { return true; } }
From source file:com.constellio.app.services.appManagement.AppManagementService.java
License:Open Source License
private void removeAllFilesAndKeepTheNewestOneBeforeLastWeek(Collection<File> files) { List<File> filesList = new ArrayList<>(files); Collections.sort(filesList, new Comparator<File>() { @Override/* w w w .j av a 2 s. co m*/ public int compare(File o1, File o2) { LocalDate modificationDate1 = new LocalDate(o1.lastModified()); LocalDate modificationDate2 = new LocalDate(o1.lastModified()); return modificationDate1.compareTo(modificationDate2); } }); for (int i = 0; i < filesList.size() - 1; i++) { File file = filesList.get(i); FileUtils.deleteQuietly(file); } File lastFile = filesList.get(filesList.size() - 1); if (!isModifiedBeforeLastWeek(lastFile)) { FileUtils.deleteQuietly(lastFile); } }
From source file:com.einzig.ipst2.sort.DateComparator.java
License:Open Source License
@Override public int compare(PortalSubmission p0, PortalSubmission p1) { LocalDate recent0, recent1; if (p0 instanceof PortalResponded) recent0 = ((PortalResponded) p0).getDateResponded(); else//from w ww. j av a2 s . c om recent0 = p0.getDateSubmitted(); if (p1 instanceof PortalResponded) recent1 = ((PortalResponded) p1).getDateResponded(); else recent1 = p0.getDateSubmitted(); return recent0.compareTo(recent1); }
From source file:com.esofthead.mycollab.validator.constraints.DateComparisionValidator.java
License:Open Source License
@Override public boolean isValid(Object value, ConstraintValidatorContext context) { try {/*w w w . ja v a 2 s. c o m*/ Date firstValue = (Date) PropertyUtils.getProperty(value, firstDateField); Date lastValue = (Date) PropertyUtils.getProperty(value, lastDateField); if (firstValue != null && lastValue != null) { LocalDate firstDate = new LocalDate(PropertyUtils.getProperty(value, firstDateField)); LocalDate lastDate = new LocalDate(PropertyUtils.getProperty(value, lastDateField)); return firstDate.compareTo(lastDate) <= 0; } return true; } catch (Exception ex) { return true; } }
From source file:com.excilys.sugadroid.services.impl.ksoap2.AppointmentServicesKsoap2Impl.java
License:Open Source License
@Override public Map<LocalDate, List<IAppointmentBean>> getAppointmentsInInterval(LocalDate start, LocalDate end) throws ServiceException { Log.d(TAG, "getAppointmentsInInterval called, days " + start.toString() + " " + end.toString()); checkLoggedIn();/*from w w w . jav a 2 s .c o m*/ if (start.compareTo(end) > 0) { throw new ServiceException("start day should be before or equal to end day"); } boolean version4_5 = sessionBean.isVersion4_5(); StringBuilder sb = new StringBuilder("meetings_users.meeting_id=meetings.id AND meetings_users.user_id='") .append(sessionBean.getUserId()).append("' AND "); if (version4_5) { sb.append("meetings.date_start>='").append(start.toString("yyyy-MM-dd")) .append("' AND meetings.date_start<'").append(end.plusDays(1).toString("yyyy-MM-dd")) .append("'"); } else { sb.append("meetings.date_start>='").append(start.toString("yyyy-MM-dd")) .append("' AND meetings.date_start<='").append(end.toString("yyyy-MM-dd")).append("'"); } String query = sb.toString(); SoapObject request = newEntryListRequest(); request.addProperty("module_name", "Meetings"); request.addProperty("query", query); if (version4_5) { request.addProperty("order_by", "meetings.date_start asc, meetings.time_start asc"); } else { request.addProperty("order_by", "meetings.date_start asc"); } request.addProperty("offset", "0"); List<String> t = new Vector<String>(); t.add("id"); t.add("name"); t.add("date_start"); if (version4_5) { t.add("time_start"); } request.addProperty("select_fields", t); request.addProperty("max_results", "1000"); request.addProperty("deleted", "0"); List<IAppointmentBean> appointments = new ArrayList<IAppointmentBean>(); if (version4_5) { appointments.addAll(getEntryList(request, AppointmentBeanV4_5.class)); } else { appointments.addAll(getEntryList(request, AppointmentBeanV5.class)); } Map<LocalDate, List<IAppointmentBean>> appointmentsInInterval = new HashMap<LocalDate, List<IAppointmentBean>>(); appointmentsInInterval.put(start, new ArrayList<IAppointmentBean>()); LocalDate day = start; while (!day.equals(end)) { day = day.plusDays(1); appointmentsInInterval.put(day, new ArrayList<IAppointmentBean>()); } for (IAppointmentBean appointment : appointments) { appointmentsInInterval.get(appointment.getDayStart()).add(appointment); } return appointmentsInInterval; }
From source file:com.excilys.sugadroid.util.EagerLoadingCalendar.java
License:Open Source License
public synchronized void setDayAppointments(LocalDate day, List<IAppointmentBean> appointments) { if (day.compareTo(minDay) < 0) { minDay = day;/*from ww w. j av a 2 s . c om*/ } else if (day.compareTo(maxDay) > 0) { maxDay = day; } List<IAppointmentBean> dayAppointments = new ArrayList<IAppointmentBean>(); dayAppointments.addAll(appointments); daysAppointments.put(day, dayAppointments); }
From source file:com.excilys.sugadroid.util.EagerLoadingCalendar.java
License:Open Source License
public boolean isDayLoaded(LocalDate day) { return day.compareTo(minDay) >= 0 && day.compareTo(maxDay) <= 0; }
From source file:com.excilys.sugadroid.util.EagerLoadingCalendar.java
License:Open Source License
public boolean isDayBeingLoaded(LocalDate day) { return !isDayLoaded(day) && day.compareTo(minPastLoadingDay) >= 0 && day.compareTo(maxFutureLoadingDay) <= 0; }