Example usage for org.joda.time Interval getEnd

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

Introduction

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

Prototype

public DateTime getEnd() 

Source Link

Document

Gets the end of this time interval, which is exclusive, as a DateTime.

Usage

From source file:org.libreplan.business.planner.limiting.entities.Gap.java

License:Open Source License

private static Gap createGap(Resource resource, Interval interval, DateAndHour originalGapStartTime,
        DateAndHour originalGapEndTime) {

    DateAndHour start = convert(originalGapStartTime, interval.getStart());
    DateAndHour end = convert(originalGapEndTime, interval.getEnd());
    return Gap.create(resource, start, end);
}

From source file:org.libreplan.business.resources.entities.CriterionSatisfaction.java

License:Open Source License

private CriterionSatisfaction(Criterion criterion, Resource resource, Interval interval) {
    this(interval.getStart(), criterion, resource);
    if (interval.getEnd() != null) {
        this.finish(interval.getEnd());
    }//from www.j av  a 2  s . com
}

From source file:org.libreplan.business.resources.entities.Resource.java

License:Open Source License

public void modifySatisfaction(CriterionSatisfaction original, Interval interval) {
    /* Create a temporal criterion satisfaction. */
    CriterionType type = original.getCriterion().getType();
    CriterionSatisfaction temporal = createNewSatisfaction(interval, original.getCriterion());
    temporal.setResource(this);

    boolean canAdd = false;
    if (contains(original)) {
        try {//from  w  w w . jav  a2s.  c o m
            removeCriterionSatisfaction(original);
            canAdd = canAddSatisfaction(type, temporal);
            if (canAdd) {
                //update original
                original.setStartDate(interval.getStart());
                original.finish(interval.getEnd());
            }
            original.validate();
            criterionSatisfactions.add(original);
            if (!canAdd) {
                throw new IllegalStateException("This interval " + original.getCriterion().getName()
                        + " not is valid because exists overlap with other criterion satisfaction");
            }
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException(original.getCriterion().getName() + " : " + e.getMessage());
        }
    } else {
        throw new IllegalStateException("The criterion satisfaction " + original.getCriterion().getName()
                + " not is activated for this resource");
    }
}

From source file:org.n52.io.img.ChartRenderer.java

License:Open Source License

protected Date getEndTime(String timespan) {
    Interval interval = Interval.parse(timespan);
    return interval.getEnd().toDate();
}

From source file:org.n52.janmayen.Times.java

License:Apache License

public static String encodeInterval(Interval interval) {
    return String.format("%s/%s", encodeDateTime(interval.getStart()), encodeDateTime(interval.getEnd()));
}

From source file:org.n52.series.db.dao.DbQuery.java

License:Open Source License

public Criteria addTimespanTo(Criteria criteria) {
    if (parameters.getTimespan() != null) {
        Interval interval = parameters.getTimespan().toInterval();
        Date start = interval.getStart().toDate();
        Date end = interval.getEnd().toDate();
        criteria.add(Restrictions.or( // check overlap
                between(COLUMN_TIMESTART, start, end), between(COLUMN_TIMEEND, start, end)));
    }/*from  www  . ja v a2  s  .  c o  m*/
    return criteria;
}

From source file:org.n52.shetland.ogc.gml.time.TimePeriod.java

License:Apache License

/**
 * Creates a new {@code TimePeriod} from an {@code Interval}.
 *
 * @param interval the interval/*from   w ww.j  a  v  a2s . c o m*/
 */
public TimePeriod(Interval interval) {
    this(interval.getStart(), interval.getEnd());
}

From source file:org.n52.tamis.core.javarepresentations.processes.execute.TimespanToSosTemporalFilterConverter.java

License:Open Source License

/**
 * Converts a timespan String that describes a time interval in IS= 8601
 * format to a SOS temporalFilter String.
 * /*from w w w  . j av a2 s  . c om*/
 * E.g.: the timespan "PT12H/2013-08-06" will be converted to the String
 * "2013-08-05T12:00:00.000Z/2013-08-06T00:00:00.000Z", which may serve as
 * temporalFIlter parameter in a SOS GetObservation request.
 * 
 * @param timespan
 *            an ISO 8601 encoded timespan.
 * @return a String, consisting of "{startTime}/{endTime}",which may serve
 *         as temporalFIlter parameter in a SOS GetObservation request
 * @throws IOException
 */
public static String convertIso8601TimespanToSosTemporalFilter(String timespan) throws IOException {
    // /*
    // * if timespan String contains a "Z" then the parsed time shall be
    // interpreted as UTC.
    // * A timespan String like "PT12H/2013-08-06Z" cannot be parsed due to
    // the final Z; parser throws malformed format exception.
    // *
    // * Hence, we set UTC and standard interpretation and remove the Z from
    // the String
    // */
    // if (encodedTimespan.contains("Z")){
    // DateTimeZone.setDefault(DateTimeZone.UTC);
    //
    // encodedTimespan.
    // }

    try {

        // set UTC as standard time
        DateTimeZone.setDefault(DateTimeZone.UTC);

        Interval timeInterval = Interval.parse(timespan);

        DateTime startTime = timeInterval.getStart();
        DateTime endTime = timeInterval.getEnd();

        String sosTemproalFilter = startTime.toString() + "/" + endTime.toString();

        return sosTemproalFilter;

    } catch (IllegalArgumentException e) {
        String message = "Could not parse timespan parameter." + timespan;
        throw new IOException(message, e);
    }
}

From source file:org.ojbc.intermediaries.sn.subscription.SubscriptionSearchQueryProcessor.java

License:RPL License

private static Element appendSubscriptionParentResponse(Subscription subscriptionSearchResponse, Document doc,
        Element subscriptionSearchResultElement, int searchResponseIndex, String extensionSchema) {

    Element subscriptionElement = XmlUtils.appendElement(subscriptionSearchResultElement, extensionSchema,
            "Subscription");

    if (subscriptionSearchResponse.getStartDate() != null || subscriptionSearchResponse.getEndDate() != null) {
        Element activityDateRangeElement = XmlUtils.appendElement(subscriptionElement,
                OjbcNamespaceContext.NS_NC, "ActivityDateRange");

        if (subscriptionSearchResponse.getStartDate() != null) {
            Element startDateParentElement = XmlUtils.appendElement(activityDateRangeElement,
                    OjbcNamespaceContext.NS_NC, "StartDate");
            Element startDateElement = XmlUtils.appendElement(startDateParentElement,
                    OjbcNamespaceContext.NS_NC, "Date");
            startDateElement.setTextContent(subscriptionSearchResponse.getStartDate().toString("yyyy-MM-dd"));
        }//from  w  w w.ja v  a2  s.  c o  m

        if (subscriptionSearchResponse.getEndDate() != null) {
            Element endDateParentElement = XmlUtils.appendElement(activityDateRangeElement,
                    OjbcNamespaceContext.NS_NC, "EndDate");
            Element endDateElement = XmlUtils.appendElement(endDateParentElement, OjbcNamespaceContext.NS_NC,
                    "Date");
            endDateElement.setTextContent(subscriptionSearchResponse.getEndDate().toString("yyyy-MM-dd"));
        }
    }

    Element subscriptionSubjectElement = XmlUtils.appendElement(subscriptionElement, extensionSchema,
            "SubscriptionSubject");

    Element roleOfPersonReferenceElement = XmlUtils.appendElement(subscriptionSubjectElement,
            OjbcNamespaceContext.NS_NC, "RoleOfPersonReference");
    XmlUtils.addAttribute(roleOfPersonReferenceElement, OjbcNamespaceContext.NS_STRUCTURES, "ref",
            "P" + searchResponseIndex);

    Element subscriptionTopicElement = XmlUtils.appendElement(subscriptionElement,
            OjbcNamespaceContext.NS_WSN_BROKERED, "Topic");
    subscriptionTopicElement.setAttribute("Dialect",
            "http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete");
    subscriptionTopicElement.setTextContent(subscriptionSearchResponse.getTopic());

    Element subscribedEntityElement = XmlUtils.appendElement(subscriptionElement, extensionSchema,
            "SubscribedEntity");
    XmlUtils.addAttribute(subscribedEntityElement, OjbcNamespaceContext.NS_STRUCTURES, "id",
            "SE" + searchResponseIndex);

    Element subscriptionOriginatorElement = XmlUtils.appendElement(subscriptionElement, extensionSchema,
            "SubscriptionOriginator");

    Element subscriptionOriginatorIdentificationElement = XmlUtils.appendElement(subscriptionOriginatorElement,
            extensionSchema, "SubscriptionOriginatorIdentification");

    Element identificationIDElement = XmlUtils.appendElement(subscriptionOriginatorIdentificationElement,
            OjbcNamespaceContext.NS_NC, "IdentificationID");
    identificationIDElement.setTextContent(subscriptionSearchResponse.getSubscriptionOwner());

    Element sourceSystemNameTextElement = XmlUtils.appendElement(subscriptionSearchResultElement,
            extensionSchema, "SourceSystemNameText");
    sourceSystemNameTextElement.setTextContent(subscriptionSearchResponse.getSubscribingSystemIdentifier());

    Element systemIdentifierElement = XmlUtils.appendElement(subscriptionSearchResultElement,
            OjbcNamespaceContext.NS_INTEL, "SystemIdentifier");

    Element sysIdentificationIDElement = XmlUtils.appendElement(systemIdentifierElement,
            OjbcNamespaceContext.NS_NC, "IdentificationID");
    sysIdentificationIDElement.setTextContent(subscriptionSearchResponse.getSubscriptionIdentifier());

    Element systemNameElement = XmlUtils.appendElement(systemIdentifierElement, OjbcNamespaceContext.NS_INTEL,
            "SystemName");
    systemNameElement.setTextContent(SUBSCRIPTION_SEARCH_RESPONSE_SYSTEM_NAME);

    DateTime validationDueDate = subscriptionSearchResponse.getValidationDueDate();
    DateTime lastValidatedDate = subscriptionSearchResponse.getLastValidationDate();

    if (validationDueDate != null || lastValidatedDate != null) {
        Element subscriptionValidationElement = XmlUtils.appendElement(subscriptionElement, extensionSchema,
                "SubscriptionValidation");
        if (validationDueDate != null) {
            Element e = XmlUtils.appendElement(subscriptionValidationElement, extensionSchema,
                    "SubscriptionValidationDueDate");
            e = XmlUtils.appendElement(e, OjbcNamespaceContext.NS_NC, "Date");
            e.setTextContent(validationDueDate.toString("yyyy-MM-dd"));
        }
        if (lastValidatedDate != null) {
            Element e = XmlUtils.appendElement(subscriptionValidationElement, extensionSchema,
                    "SubscriptionValidatedDate");
            e = XmlUtils.appendElement(e, OjbcNamespaceContext.NS_NC, "Date");
            e.setTextContent(lastValidatedDate.toString("yyyy-MM-dd"));
        }
    }

    Interval gracePeriodInterval = subscriptionSearchResponse.getGracePeriod();

    if (gracePeriodInterval != null) {
        Element gracePeriodElement = XmlUtils.appendElement(subscriptionElement, extensionSchema,
                "SubscriptionGracePeriod");
        Element gracePeriodDateRangeElement = XmlUtils.appendElement(gracePeriodElement, extensionSchema,
                "SubscriptionGracePeriodDateRange");
        Element e = XmlUtils.appendElement(gracePeriodDateRangeElement, OjbcNamespaceContext.NS_NC,
                "StartDate");
        e = XmlUtils.appendElement(e, OjbcNamespaceContext.NS_NC, "Date");
        e.setTextContent(gracePeriodInterval.getStart().toString("yyyy-MM-dd"));
        e = XmlUtils.appendElement(gracePeriodDateRangeElement, OjbcNamespaceContext.NS_NC, "EndDate");
        e = XmlUtils.appendElement(e, OjbcNamespaceContext.NS_NC, "Date");
        e.setTextContent(gracePeriodInterval.getEnd().toString("yyyy-MM-dd"));
    }

    String categoryReasonCode = subscriptionSearchResponse.getSubscriptionCategoryCode();

    if (StringUtils.isNotEmpty(categoryReasonCode)) {

        Element reasonCodeElement = XmlUtils.appendElement(subscriptionElement, extensionSchema,
                "CriminalSubscriptionReasonCode");
        reasonCodeElement.setTextContent(categoryReasonCode);
    }
    return subscriptionElement;
}

From source file:org.opendatakit.common.android.utilities.DataUtil.java

License:Apache License

public String formatIntervalForDb(Interval interval) {
    return formatDateTimeForDb(interval.getStart()) + "/" + formatDateTimeForDb(interval.getEnd());
}