public AlertEvent( String service, String host, String description, Map<String, Object> dataMap ) { this(DateTimes.nowUtc(), service, host, Severity.DEFAULT, description, dataMap); }
DateTime truncatedDateTime = segmentGranularity.bucketStart(DateTimes.utc(timestamp)); final Interval interval = new Interval(truncatedDateTime, segmentGranularity.increment(truncatedDateTime));
public DateTime getTimestamp() { Object retVal = event.get(timestampKey); if (retVal instanceof Long) { return DateTimes.utc((Long) retVal); } else if (retVal instanceof String) { return DateTimes.of((String) retVal); } else if (retVal instanceof DateTime) { return (DateTime) retVal; } else { throw new ISE("Do not understand format [%s]", retVal.getClass()); } }
final DateTimes.UtcFormatter parser = DateTimes.wrapFormatter(createAutoParser()); return (String input) -> { Preconditions.checkArgument(!Strings.isNullOrEmpty(input), "null timestamp"); return DateTimes.utc(Long.parseLong(input)); }; } else if (format.equalsIgnoreCase("iso")) { return input -> { Preconditions.checkArgument(!Strings.isNullOrEmpty(input), "null timestamp"); return DateTimes.of(ParserUtils.stripQuotes(input)); }; } else if (format.equalsIgnoreCase("posix") } else { try { final DateTimes.UtcFormatter formatter = DateTimes.wrapFormatter(DateTimeFormat.forPattern(format)); return input -> { Preconditions.checkArgument(!Strings.isNullOrEmpty(input), "null timestamp");
@Override public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException, JsonProcessingException { return DateTimes.of(key); } }
formatString == null ? createDefaultParser(timeZone) : DateTimes.wrapFormatter(DateTimeFormat.forPattern(formatString).withZone(timeZone));
private static Iterable<Interval> splitInterval(Interval interval, Period period) { if (interval.getEndMillis() == interval.getStartMillis()) { return Lists.newArrayList(interval); } List<Interval> intervals = Lists.newArrayList(); Iterator<Interval> timestamps = new PeriodGranularity(period, null, null).getIterable(interval).iterator(); DateTime start = DateTimes.max(timestamps.next().getStart(), interval.getStart()); while (timestamps.hasNext()) { DateTime end = timestamps.next().getStart(); intervals.add(new Interval(start, end)); start = end; } if (start.compareTo(interval.getEnd()) < 0) { intervals.add(new Interval(start, interval.getEnd())); } return intervals; }
@Override @Nullable public String apply(@Nullable Object value) { if (value == null) { return null; } if (asMillis && value instanceof String) { final Long theLong = GuavaUtils.tryParseLong((String) value); return theLong == null ? apply(DateTimes.of((String) value).getMillis()) : apply(theLong.longValue()); } else { return apply(new DateTime(value, ISOChronology.getInstanceUTC()).getMillis()); } }
.toParser(); return DateTimes.wrapFormatter( new DateTimeFormatterBuilder() .append(ISODateTimeFormat.dateElementParser())
@Override public DateTime getCurrMaxTime() { return DateTimes.nowUtc(); }
DateTime truncatedDateTime = segmentGranularity.bucketStart(DateTimes.utc(truncatedTime)); final Interval interval = new Interval(truncatedDateTime, segmentGranularity.increment(truncatedDateTime));
@Nullable private DateTime getDateTimeValue(@Nullable Object val) { if (val == null) { return null; } if (val instanceof DateTime) { return (DateTime) val; } else if (val instanceof String) { return DateTimes.of((String) val); } else if (val instanceof Long) { return DateTimes.utc((Long) val); } else { throw new IAE("Cannot get time from type[%s]", val.getClass()); } } }
@Override @Nullable public Pair<DateTime, String> getCreatedDateAndDataSource(String entryId) { return connector.retryWithHandle( handle -> handle .createQuery( StringUtils.format( "SELECT created_date, datasource FROM %s WHERE id = :entryId", entryTable ) ) .bind("entryId", entryId) .map( (index, resultSet, ctx) -> Pair.of( DateTimes.of(resultSet.getString("created_date")), resultSet.getString("datasource") ) ) .first() ); }
public AlertEvent( String service, String host, Severity severity, String description, Map<String, Object> dataMap ) { this(DateTimes.nowUtc(), service, host, severity, description, dataMap); }
@Override public DateTime getCurrMaxTime() { return DateTimes.utc(maxTimestamp); }
timeline.lookup(new Interval(DateTimes.EPOCH, DateTimes.of("3000-01-01")));
public TaskRunnerWorkItem(String taskId, ListenableFuture<TaskStatus> result) { this(taskId, result, DateTimes.nowUtc()); }
public DateTime toDateTime(long offset) { return DateTimes.utc(offset); }