List of usage examples for org.joda.time LocalDate toInterval
public Interval toInterval()
From source file:com.stagecents.common.EffectiveDateInterval.java
License:Open Source License
public boolean isEffective(LocalDate effectiveDate) { Interval period = new Interval(startDate, endDate); return period.contains(effectiveDate.toInterval()); }
From source file:fi.hsl.parkandride.core.service.FacilityHistoryService.java
License:EUPL
private static <T extends HasInterval> T findEntryForDate(List<T> entries, LocalDate date, T identity) { final Interval significantWindow = windowForDate(date); return entries.stream().filter(e -> e.getInterval().overlaps(date.toInterval())) .collect(reducing(identity, greatestOverlap(significantWindow))); }
From source file:org.estatio.dom.utils.CalendarUtils.java
License:Apache License
public static Interval currentInterval(final LocalDate date, final String rrule, final LocalDate startDate) { if (date == null || startDate == null || rrule == null) { return null; }/*from w w w . j a v a 2 s.c om*/ try { LocalDate thisDate = startDate; final LocalDateIterator iter = LocalDateIteratorFactory.createLocalDateIterator(rrule, thisDate, true); while (iter.hasNext()) { LocalDate nextDate = iter.next(); if (nextDate.compareTo(date) > 0) { return new Interval(thisDate.toInterval().getStartMillis(), nextDate.toInterval().getStartMillis()); } thisDate = nextDate; } } catch (final ParseException ex) { throw new EstatioApplicationException("Unable to parse rrule >>" + rrule + "<<", ex); } return null; }
From source file:org.estatio.dom.valuetypes.AbstractInterval.java
License:Apache License
/** * Does this date contain the specified time interval. * /*from www . ja v a2s . com*/ * @param date * @return */ public boolean contains(final LocalDate date) { if (date == null) { return false; } if (endDate() == null) { if (startDate() == null) { return true; } if (date.isEqual(startDate()) || date.isAfter(startDate())) { return true; } return false; } return asInterval().contains(date.toInterval()); }
From source file:org.estatio.dscm.utils.CalendarUtils.java
License:Apache License
public static Interval currentInterval(final LocalDate date, final String rrule, final LocalDate startDate) { if (date == null || startDate == null || rrule == null) { return null; }//from ww w. j a v a 2 s . c o m try { LocalDate thisDate = startDate; final LocalDateIterator iter = LocalDateIteratorFactory.createLocalDateIterator(rrule, thisDate, true); while (iter.hasNext()) { LocalDate nextDate = iter.next(); if (nextDate.compareTo(date) > 0) { return new Interval(thisDate.toInterval().getStartMillis(), nextDate.toInterval().getStartMillis()); } thisDate = nextDate; } } catch (final ParseException ex) { throw new IllegalArgumentException("Unable to parse rrule >>" + rrule + "<<", ex); } return null; }
From source file:org.springframework.ws.samples.airline.service.impl.AirlineServiceImpl.java
License:Apache License
public List<Flight> getFlights(String fromAirportCode, String toAirportCode, LocalDate departureDate, ServiceClass serviceClass) {/*from w ww . j av a 2 s. c o m*/ if (serviceClass == null) { serviceClass = ServiceClass.ECONOMY; } if (logger.isDebugEnabled()) { logger.debug("Getting flights from '" + fromAirportCode + "' to '" + toAirportCode + "' on " + departureDate); } List<Flight> flights = flightDao.findFlights(fromAirportCode, toAirportCode, departureDate.toInterval(), serviceClass); if (logger.isDebugEnabled()) { logger.debug("Returning " + flights.size() + " flights"); } return flights; }