List of usage examples for org.joda.time Interval getStart
public DateTime getStart()
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/*ww w . j a v a 2 s. 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 ww . j ava2s.c o m * 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")); }//ww w . j a v a 2 s . c om 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 validifyDateValue(String input) { DateTime instant = tryParseInstant(input); if (instant != null) { return formatDateTimeForDb(instant); }/*from w ww.ja v a2 s.c o m*/ Interval interval = tryParseInterval(input); if (interval != null) { return formatDateTimeForDb(interval.getStart()); } return null; }
From source file:org.opendatakit.common.android.utilities.DataUtil.java
License:Apache License
public String validifyDateTimeValue(String input) { DateTime instant = tryParseInstant(input); if (instant != null) { return formatDateTimeForDb(instant); }/*from w ww.j a v a 2 s . c o m*/ Interval interval = tryParseInterval(input); if (interval != null) { return formatDateTimeForDb(interval.getStart()); } return null; }
From source file:org.opendatakit.common.android.utilities.DataUtil.java
License:Apache License
public String validifyTimeValue(String input) { // TODO: does this need to be different? // Need to respect TimeZone. What should Date be? DateTime instant = tryParseInstant(input); if (instant != null) { return formatDateTimeForDb(instant); }// w ww . j a v a2s.c o m Interval interval = tryParseInterval(input); if (interval != null) { return formatDateTimeForDb(interval.getStart()); } return null; }
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()); }
From source file:org.opendatakit.common.android.utilities.DataUtil.java
License:Apache License
public String formatShortIntervalForUser(Interval interval) { return formatShortDateTimeForUser(interval.getStart()) + "-" + formatShortDateTimeForUser(interval.getEnd()); }
From source file:org.opendatakit.common.android.utilities.DataUtil.java
License:Apache License
public String formatLongIntervalForUser(Interval interval) { return formatLongDateTimeForUser(interval.getStart()) + " - " + formatLongDateTimeForUser(interval.getEnd()); }
From source file:org.opendatakit.tables.data.DataUtil.java
License:Apache License
private String validifyDateValue(String input) { DateTime instant = tryParseInstant(input); if (instant != null) { return formatDateTimeForDb(instant); }//from w ww . j a va 2 s. c o m Interval interval = tryParseInterval(input); if (interval != null) { return formatDateTimeForDb(interval.getStart()); } return null; }