result = Interval.parse(v); } else { start = Long.valueOf(str);
/** * @param timespan * the time interval in ISO8601 notation. * @throws IllegalArgumentException * if timespan is not a valid interval. */ public IntervalWithTimeZone(String timespan) { Interval.parse(timespan); this.timespan = timespan; }
public Interval convertToEntityAttribute(String string) { return Interval.parse(string); } }
public Interval toInterval() { return Interval.parse(timespan); }
public Interval toInterval() { return Interval.parse(timespan); }
protected Date getEndTime(String timespan) { Interval interval = Interval.parse(timespan); return interval.getEnd() .toDate(); }
protected Date getStartTime(String timespan) { Interval interval = Interval.parse(timespan); return interval.getStart() .toDate(); }
protected Date getEndTime(String timespan) { Interval interval = Interval.parse(timespan); return interval.getEnd() .toDate(); }
protected Date getStartTime(String timespan) { Interval interval = Interval.parse(timespan); return interval.getStart() .toDate(); }
/** * @param timespan the time interval in ISO8601 notation. * @throws IoParseException if timespan is not a valid interval. */ public IntervalWithTimeZone(String timespan) { try { Interval.parse(timespan); this.timespan = timespan; } catch (IllegalArgumentException e) { String message = "Could not parse timespan parameter." + timespan; throw new IoParseException(message, e); } }
private String validateTimespan(String timespan) { return Interval.parse(timespan).toString(); }
public List<DateTime> extractMinMaxTime() { if(CollectionUtils.isEmpty(this.intervals)) { DateTime now = DateTime.now(); return Lists.newArrayList(now.minusYears(5), now); } Interval firstInterval = Interval.parse(this.intervals.get(0)); if(this.intervals.size() == 1) { return Lists.newArrayList(firstInterval.getStart(), firstInterval.getEnd()); } Interval lastInterval = Interval.parse(this.intervals.get(this.intervals.size()-1)); return Lists.newArrayList(firstInterval.getStart(), lastInterval.getEnd()); }
private void checkAgainstTimespanRestriction(String timespan) { Duration duration = Period.parse(requestIntervalRestriction).toDurationFrom(new DateTime()); if (duration.getMillis() < Interval.parse(timespan).toDurationMillis()) { throw new BadRequestException("Requested timespan is to long, please use a period shorter than '" + requestIntervalRestriction + "'"); } }
public void validateIntervals(List<String> intervals) { this.intervals = Lists.newArrayList(); for (String interval : intervals) { if(StringUtils.isEmpty(interval)) { throw new IllegalArgumentException("Invalid interval format : " + interval); } Interval plusEndInterval; try { Interval parsedInterval = Interval.parse(replaceCurrentTime(interval)); plusEndInterval = parsedInterval.withEnd(parsedInterval.getEnd().plusSeconds(1)); } catch (Exception e) { throw new IllegalArgumentException("Invalid interval format : " + interval); } this.intervals.add(plusEndInterval.toString()); } }
/** * Returns a {@link org.joda.time.Interval} instance representing the specified {@link String} {@literal value}. * * @param value The configuration parameter's {@link String} value * @return A {@link org.joda.time.Interval} instance representing the configuration parameter's value * @see Interval#parse(String) */ @Override public Interval convertFrom(String value) { if(null == value) { throw new ParameterException("Couldn't convert \"null\" to Interval."); } try { return Interval.parse(value); } catch (Exception ex) { throw new ParameterException("Couldn't convert value \"" + value + "\" to Interval.", ex); } }
private void checkAgainstTimespanRestriction(IntervalWithTimeZone timespan) { Duration duration = Period.parse(requestIntervalRestriction) .toDurationFrom(new DateTime()); if (duration.getMillis() < Interval.parse(timespan.toString()) .toDurationMillis()) { throw new BadRequestException("Requested timespan is to long, please use a period shorter than '" + requestIntervalRestriction + "'"); } }
private void checkAgainstTimespanRestriction(IntervalWithTimeZone timespan) { if (requestIntervalRestriction != null) { Duration duration = Period.parse(requestIntervalRestriction) .toDurationFrom(new DateTime()); if (duration.getMillis() < Interval.parse(timespan.toString()) .toDurationMillis()) { throw new BadRequestException("Timespan too long, please use a period shorter than '" + requestIntervalRestriction + "'"); } } }
@Override public void run(CommandLine line, ToolRunningContext context) throws Exception { Interval interval = Interval.parse(line.getOptionValue("interval")); HistoDbHorizon horizon = HistoDbHorizon.SN; if (line.hasOption("horizon")) { horizon = HistoDbHorizon.valueOf(line.getOptionValue("horizon")); } OfflineConfig config = OfflineConfig.load(); try (HistoDbClient histoDbClient = config.getHistoDbClientFactoryClass().newInstance().create(true)) { Set<HistoDbAttributeId> attributeIds = new LinkedHashSet<>(histoDbClient.listAttributes()); HistoDbStats stats = histoDbClient.queryStats(attributeIds, interval, horizon, true); for (HistoDbAttributeId attributeId : attributeIds) { context.getOutputStream().println(attributeId + ";" + (int) stats.getValue(HistoDbStatsType.COUNT, attributeId, -1)); } } } }
protected DesignOptions createDesignOptions(ParameterSet parameterSet, ArrayList<TimeseriesProperties> props, boolean renderGrid) { Interval timespan = Interval.parse(parameterSet.getTimespan()); long begin = timespan.getStartMillis(); long end = timespan.getEndMillis(); return new DesignOptions(props, begin, end, renderGrid); }
public DataSource.GranularityType getGranularityType(Granularity granularity) { if (granularity instanceof PeriodGranularity) { Period period = Period.parse(((PeriodGranularity) granularity).getPeriod()); return DataSource.GranularityType.fromPeriod(period); } else if (granularity instanceof DurationGranularity) { Interval interval = Interval.parse(((DurationGranularity) granularity).getDuration()); return DataSource.GranularityType.fromInterval(interval); } else { return DataSource.GranularityType.valueOf(((SimpleGranularity) granularity).getValue()); } }