Example usage for org.joda.time LocalTime isBefore

List of usage examples for org.joda.time LocalTime isBefore

Introduction

In this page you can find the example usage for org.joda.time LocalTime isBefore.

Prototype

public boolean isBefore(ReadablePartial partial) 

Source Link

Document

Is this partial earlier than the specified partial.

Usage

From source file:aiai.ai.yaml.env.TimePeriods.java

License:Open Source License

public boolean isActive(LocalTime curr, TimePeriod period) {
    return curr.isEqual(period.start) || curr.isEqual(period.end)
            || (curr.isAfter(period.start) && curr.isBefore(period.end));
}

From source file:com.helger.datetime.period.LocalTimePeriod.java

License:Apache License

public final boolean isValidFor(@Nonnull final LocalTime aDate) {
    if (aDate == null)
        throw new NullPointerException("date");

    final LocalTime aStart = getStart();
    if (aStart != null && aStart.isAfter(aDate))
        return false;
    final LocalTime aEnd = getEnd();
    if (aEnd != null && aEnd.isBefore(aDate))
        return false;
    return true;//www .ja v  a2 s . c  o  m
}

From source file:com.hotwire.test.steps.search.air.AirSearchModelWebApp.java

License:Open Source License

private void compareValues(LocalTime a, LocalTime b, boolean doAscendingOrderBy) {
    LOGGER.info("Compare " + b + (doAscendingOrderBy ? " <= " : " >= ") + a);
    if (doAscendingOrderBy) {
        assertThat(a.isEqual(b) || a.isAfter(b))
                .as("Expected (" + a + " <= " + b + ") to be true but got false instead.").isTrue();
    } else {/*ww w .j a v  a2  s  . co m*/
        // Descending order.
        assertThat(a.isEqual(b) || a.isBefore(b))
                .as("Expected (" + a + " >= " + b + ") to be true but got false instead.").isTrue();
    }
}

From source file:com.jive.myco.seyren.core.domain.Subscription.java

License:Apache License

private boolean isCorrectHourOfDay(DateTime time) {
    LocalTime alertTime = new LocalTime(time.getHourOfDay(), time.getMinuteOfHour());
    return alertTime.isAfter(getFromTime()) && alertTime.isBefore(getToTime());
}

From source file:com.karthikb351.vitinfo2.fragment.schedule.ScheduleListAdapter.java

License:Open Source License

private void compareTimeAndUpdate(ScheduleView scheduleView, String startTime, String endTime) {

    // Formatting strings to get the nearest hours
    startTime = formatTime(startTime);/*from   w  ww.  j a  va  2s .  c  o m*/
    endTime = formatTime(endTime);

    // Comparing time
    LocalTime nowTime = LocalTime.now(DateTimeZone.UTC);
    LocalTime floorTime = new LocalTime(startTime);
    LocalTime ceilTime = new LocalTime(endTime);

    // To correct the timezone difference
    nowTime = nowTime.plusHours(5);
    nowTime = nowTime.plusMinutes(30);

    boolean lowerCheck = nowTime.isAfter(floorTime) || nowTime.isEqual(floorTime);
    boolean upperCheck = nowTime.isBefore(ceilTime);
    boolean upperOverCheck = nowTime.isAfter(ceilTime) || nowTime.isEqual(ceilTime);

    if (lowerCheck && upperCheck) {
        scheduleView.setState(TimeLineView.STATE_CURRENT);
    } else if (lowerCheck && upperOverCheck) {
        scheduleView.setState(TimeLineView.STATE_FINISHED);
    } else {
        scheduleView.setState(TimeLineView.STATE_SCHEDULED);
    }
}

From source file:com.qcadoo.commons.dateTime.TimeRange.java

License:Open Source License

/**
 * Check if given time is included in this time range. If from & to boundaries is in reversed order (time from is greater than
 * to; startsDayBefore() returns true) then it will be checked that given time is contained in range [from time = midnight
 * (inclusive)] or [midnight - to time].
 * //from   w w w . j a v a  2s  .c  o  m
 * @param time
 * @return true if this time range contains given time.
 */
public boolean contains(final LocalTime time) {
    if (startsDayBefore()) {
        return !time.isAfter(to) || !time.isBefore(from);
    }
    return !time.isAfter(to) && !time.isBefore(from);
}

From source file:com.qcadoo.mes.productionPerShift.dates.OrderRealizationDaysResolver.java

License:Open Source License

private Function<TimeRange, Boolean> endsNextDay(final LocalTime orderStartTime) {
    return timeRange -> timeRange.startsDayBefore() && !orderStartTime.isBefore(timeRange.getFrom());
}

From source file:de.appsolve.padelcampus.utils.BookingUtil.java

public void checkForBookedCourts(TimeSlot timeSlot, List<Booking> confirmedBookings,
        Boolean preventOverlapping) {
    LocalTime startTime = timeSlot.getStartTime();
    LocalTime endTime = timeSlot.getEndTime();

    for (Booking booking : confirmedBookings) {

        if (timeSlot.getDate().equals(booking.getBookingDate())) {
            LocalTime bookingStartTime = booking.getBookingTime();
            LocalTime bookingEndTime = bookingStartTime.plusMinutes(booking.getDuration().intValue());
            Boolean addBooking = false;
            if (preventOverlapping) {
                if (startTime.isBefore(bookingEndTime)) {
                    if (endTime.isAfter(bookingStartTime)) {
                        addBooking = true;
                    }/*from   w w  w  .ja  va2  s  . com*/
                }
            } else {
                //for displaying allocations
                if (startTime.compareTo(bookingStartTime) >= 0) {
                    if (endTime.compareTo(bookingEndTime) <= 0) {
                        addBooking = true;
                    }
                }
            }
            if (addBooking) {
                Offer offer = booking.getOffer();
                for (Offer timeSlotOffer : timeSlot.getConfig().getOffers()) {
                    if (offer.equals(timeSlotOffer)) {
                        timeSlot.addBooking(booking);
                        break;
                    }
                }
            }
        }
    }
}

From source file:dk.teachus.backend.domain.impl.PeriodImpl.java

License:Apache License

public boolean mayBook(LocalTime time) {
    boolean mayBook = false;

    if (isTimeValid(time)) {
        time = time.plusMinutes(lessonDuration);
        if (time.equals(endTime) || time.isBefore(endTime)) {
            mayBook = true;/*from   ww  w  .ja  va2s. c o  m*/
        }
    }

    return mayBook;
}

From source file:dk.teachus.frontend.components.calendar.PeriodsCalendarPanel.java

License:Apache License

@Override
protected LocalTime getCalendarStartTime() {
    LocalTime calendarStartTime = super.getCalendarStartTime();

    CalendarNarrowTimesTeacherAttribute narrowTimes = TeachUsSession.get()
            .getTeacherAttribute(CalendarNarrowTimesTeacherAttribute.class);
    if (narrowTimes != null && narrowTimes.getBooleanValue()) {
        LocalTime earliestStart = new LocalTime(23, 59, 59, 999);
        List<DatePeriod> periods = datePeriodsModel.getObject();
        for (DatePeriod datePeriod : periods) {
            List<Period> periodList = datePeriod.getPeriods();
            for (Period period : periodList) {
                LocalTime periodStartTime = period.getStartTime();
                if (periodStartTime.isBefore(earliestStart)) {
                    earliestStart = periodStartTime;
                }/* w w  w  . j  a  v a 2  s .  co m*/
            }
        }
        calendarStartTime = earliestStart;
    }

    return calendarStartTime;
}