Example usage for org.joda.time Interval abuts

List of usage examples for org.joda.time Interval abuts

Introduction

In this page you can find the example usage for org.joda.time Interval abuts.

Prototype

public boolean abuts(ReadableInterval interval) 

Source Link

Document

Does this interval abut with the interval specified.

Usage

From source file:org.jasig.portlet.calendar.mvc.CalendarDisplayEvent.java

License:Apache License

/**
 * Constructs an object from specified data.
 *
 * @param event "Raw" Event object//from ww  w . j a v a2 s. co m
 * @param eventInterval Interval portion of the event that applies to this specific day
 * @param theSpecificDay Interval of the specific day in question
 * @param df date formatter to represent date displays
 * @param tf time formatter to represent time displays
 */
public CalendarDisplayEvent(VEvent event, Interval eventInterval, Interval theSpecificDay, DateTimeFormatter df,
        DateTimeFormatter tf) {
    assert theSpecificDay.abuts(eventInterval)
            || theSpecificDay.overlaps(eventInterval) : "Event interval is not in the specified day!";

    this.summary = event.getSummary() != null ? event.getSummary().getValue() : null;
    this.description = event.getDescription() != null ? event.getDescription().getValue() : null;
    this.location = event.getLocation() != null ? event.getLocation().getValue() : null;

    boolean multi = false;
    if (eventInterval.getStart().isBefore(theSpecificDay.getStart())) {
        dayStart = theSpecificDay.getStart();
        multi = true;
    } else {
        dayStart = eventInterval.getStart();
    }

    if (event.getEndDate() == null) {
        dayEnd = dayStart;
    } else if (eventInterval.getEnd().isAfter(theSpecificDay.getEnd())) {
        dayEnd = theSpecificDay.getEnd();
        multi = true;
    } else {
        dayEnd = eventInterval.getEnd();
    }
    this.isMultiDay = multi;

    this.dateStartTime = tf.print(dayStart);
    this.startTime = tf.print(eventInterval.getStart());
    this.startDate = df.print(eventInterval.getStart());

    if (event.getEndDate() != null) {
        this.dateEndTime = tf.print(dayEnd);
        this.endTime = tf.print(eventInterval.getEnd());
        this.endDate = df.print(eventInterval.getEnd());
    } else {
        this.dateEndTime = null;
        this.endTime = null;
        this.endDate = null;
    }

    Interval dayEventInterval = new Interval(dayStart, dayEnd);
    this.isAllDay = dayEventInterval.equals(theSpecificDay);

}