Example usage for org.joda.time LocalTime isAfter

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

Introduction

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

Prototype

public boolean isAfter(ReadablePartial partial) 

Source Link

Document

Is this partial later 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.j  a  va 2 s . co  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 {//  w  w w .  java 2 s  . c o  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. jav  a 2 s. co 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].
 * /*  ww w  . ja v  a 2 s . co  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> startsDayBefore(final LocalTime orderStartTime) {
    return timeRange -> timeRange.startsDayBefore() && !orderStartTime.isAfter(timeRange.getTo());
}

From source file:de.appsolve.padelcampus.controller.bookings.BookingsVoucherController.java

@RequestMapping(value = "booking/{UUID}/voucher", method = POST)
public ModelAndView onPostVoucher(@PathVariable("UUID") String UUID,
        @RequestParam(required = false) String voucherUUID) {
    Booking booking = bookingDAO.findByUUID(UUID);
    ModelAndView mav = getVoucherView(booking);
    try {//from ww w.  jav a  2  s . com
        if (booking.getConfirmed()) {
            throw new Exception(msg.get("BookingAlreadyConfirmed"));
        }
        if (StringUtils.isEmpty(voucherUUID)) {
            throw new Exception(msg.get("MissingRequiredVoucher"));
        }
        Voucher voucher = voucherDAO.findByUUID(voucherUUID);
        LocalDate now = new LocalDate();

        if (voucher == null) {
            throw new Exception(msg.get("VoucherDoesNotExist"));
        }

        if (voucher.getUsed()) {
            throw new Exception(msg.get("VoucherHasAlreadyBeenUsed"));
        }

        if (now.isAfter(voucher.getValidUntil())) {
            throw new Exception(msg.get("VoucherHasExpired"));
        }

        if (voucher.getDuration().compareTo(booking.getDuration()) < 0) {
            throw new Exception(
                    msg.get("VoucherIsOnlyValidForDuration", new Object[] { voucher.getDuration() }));
        }

        if (!voucher.getOffers().contains(booking.getOffer())) {
            throw new Exception(msg.get("VoucherIsOnlyValidForOffer", new Object[] { voucher.getOffers() }));
        }

        LocalTime validUntilTime = voucher.getValidUntilTime();
        LocalTime bookingEndTime = booking.getBookingEndTime();
        if (bookingEndTime.isAfter(validUntilTime)) {
            throw new Exception(msg.get("VoucherIsOnlyValidForBookingsBefore",
                    new Object[] { validUntilTime.toString(TIME_HUMAN_READABLE) }));
        }

        //update legacy vouchers
        if (voucher.getCalendarWeekDays().isEmpty()) {
            voucher.setCalendarWeekDays(new HashSet<>(Arrays.asList(CalendarWeekDay.values())));
        }

        Set<CalendarWeekDay> validWeekDays = voucher.getCalendarWeekDays();
        CalendarWeekDay bookingWeekDay = CalendarWeekDay.values()[booking.getBookingDate().getDayOfWeek() - 1];
        if (!validWeekDays.contains(bookingWeekDay)) {
            throw new Exception(msg.get("VoucherIsOnlyValidForBookingsOn", new Object[] { validWeekDays }));
        }

        voucher.setUsed(true);
        voucherDAO.saveOrUpdate(voucher);
        booking.setPaymentConfirmed(true);
        booking.setVoucher(voucher);
        bookingDAO.saveOrUpdate(booking);
        return BookingsController.getRedirectToSuccessView(booking);
    } catch (Exception e) {
        log.error(e);
        mav.addObject("error", e.getMessage());
        return mav;
    }
}

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;
                    }/* w  w w  .  j av  a2s  .c  o  m*/
                }
            } 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:de.phoenix.rs.entity.PhoenixDetails.java

License:Open Source License

/**
 * Constructor for client/server//from ww  w.j  av  a 2s  . co  m
 * 
 * @param room
 *            The room where the event is happening
 * @param weekday
 *            The day of the week
 * @param startTime
 *            The time when the events starts
 * @param interval
 *            The interval of the event. Will be replaced by an enum
 * @param startDate
 *            The start date of the event(before this date, the event does
 *            not exist!)
 * @param endDate
 *            The end date of the event(after this date, the event does not
 *            exist!)
 */
public PhoenixDetails(String room, Weekday weekday, LocalTime startTime, LocalTime endTime, Period interval,
        LocalDate startDate, LocalDate endDate) {
    this.room = room;
    this.weekday = weekday;
    this.startTime = startTime;
    this.endTime = endTime;
    this.interval = interval;
    this.startDate = startDate;
    this.endDate = endDate;

    if (startTime.isAfter(endTime))
        throw new InvalidParameterException("StartTime is after EndTime!");
    if (startDate.isAfter(endDate))
        throw new InvalidParameterException("StartDate is after EndDate!");
}