use of org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime in project arctic-sea by 52North.
the class SweCommonDecoderV101 method parseTimeRange.
private SweTimeRange parseTimeRange(TimeRange timeRange) throws DecodingException {
SweTimeRange sosTimeRange = new SweTimeRange();
if (timeRange.isSetValue()) {
RangeValue<DateTime> range = new RangeValue<>();
Iterator<?> iter = timeRange.getValue().iterator();
if (iter.hasNext()) {
range.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iter.next().toString()));
while (iter.hasNext()) {
range.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iter.next().toString()));
}
}
sosTimeRange.setValue(range);
}
if (timeRange.getUom() != null) {
sosTimeRange.setUom(timeRange.getUom().getHref());
}
return sosTimeRange;
}
use of org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime in project arctic-sea by 52North.
the class SweCommonDecoderV101 method parseAllowedTimes.
@SuppressWarnings({ "unchecked", "rawtypes" })
private SweAllowedTimes parseAllowedTimes(AllowedTimes att) throws DateTimeParseException {
SweAllowedTimes allowedTimes = new SweAllowedTimes();
if (att.isSetId()) {
allowedTimes.setGmlId(att.getId());
}
if (CollectionHelper.isNotNullOrEmpty(att.getValueListArray())) {
for (List list : att.getValueListArray()) {
if (CollectionHelper.isNotEmpty(list)) {
for (Object value : list) {
allowedTimes.addValue(DateTimeHelper.parseIsoString2DateTime(value.toString()));
}
}
}
}
if (CollectionHelper.isNotNullOrEmpty(att.getIntervalArray())) {
for (List interval : att.getIntervalArray()) {
RangeValue<DateTime> rangeValue = new RangeValue<DateTime>();
Iterator iterator = interval.iterator();
if (iterator.hasNext()) {
rangeValue.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
}
if (iterator.hasNext()) {
rangeValue.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
}
allowedTimes.addInterval(rangeValue);
}
}
return allowedTimes;
}
use of org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime in project arctic-sea by 52North.
the class SweCommonDecoderV20 method parseAllowedTimes.
@SuppressWarnings("rawtypes")
private SweAllowedTimes parseAllowedTimes(AllowedTimesType att) throws DateTimeParseException {
SweAllowedTimes allowedTimes = new SweAllowedTimes();
if (att.isSetId()) {
allowedTimes.setGmlId(att.getId());
}
if (CollectionHelper.isNotNullOrEmpty(att.getValueArray())) {
for (Object value : att.getValueArray()) {
allowedTimes.addValue(DateTimeHelper.parseIsoString2DateTime(value.toString()));
}
}
if (CollectionHelper.isNotNullOrEmpty(att.getIntervalArray())) {
for (List interval : att.getIntervalArray()) {
RangeValue<DateTime> rangeValue = new RangeValue<DateTime>();
Iterator iterator = interval.iterator();
if (iterator.hasNext()) {
rangeValue.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
}
if (iterator.hasNext()) {
rangeValue.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
}
allowedTimes.addInterval(rangeValue);
}
}
if (att.isSetSignificantFigures()) {
allowedTimes.setSignificantFigures(att.getSignificantFigures());
}
return allowedTimes;
}
use of org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime in project arctic-sea by 52North.
the class GmlDecoderv311 method parseTimePosition.
private TimeInstant parseTimePosition(TimePositionType xbTimePosition) throws DecodingException {
TimeInstant ti = new TimeInstant();
String timeString = xbTimePosition.getStringValue();
if (timeString != null && !timeString.isEmpty()) {
try {
// TODO better differnetiate between ISO8601 and an
// indeterminate value
DateTime dateTime = DateTimeHelper.parseIsoString2DateTime(timeString);
ti.setValue(dateTime);
ti.setRequestedTimeLength(DateTimeHelper.getTimeLengthBeforeTimeZone(timeString));
} catch (DateTimeParseException ex) {
ti.setIndeterminateValue(new IndeterminateValue(timeString));
}
}
if (xbTimePosition.getIndeterminatePosition() != null) {
ti.setIndeterminateValue(new IndeterminateValue(xbTimePosition.getIndeterminatePosition().toString()));
}
return ti;
}
use of org.n52.shetland.util.DateTimeHelper.parseIsoString2DateTime in project arctic-sea by 52North.
the class FieldDecoderTest method before.
@Before
public void before() throws DecodingException {
this.decoder = new FieldDecoder();
this.timeStart = DateTimeHelper.parseIsoString2DateTime(TIME_START);
this.timeEnd = DateTimeHelper.parseIsoString2DateTime(TIME_END);
this.validator = JSONValidator.getInstance();
}
Aggregations