public static Date getFormattedDate(String dateString) { return searchDateFormat.parseDateTime(dateString).toDate(); }
public void logJson(RestResponse response, long contentLength, long now) { long latency = now - timestamp; DateTime nowdt = new DateTime(now); DateTime startdt = new DateTime(timestamp); try { XContentBuilder json = XContentFactory.jsonBuilder().startObject(); json.field("time", nowdt.toDateTimeISO().toString()); json.field("starttime", startdt.toDateTimeISO().toString()); json.field("localaddr", localaddr); json.field("localport", localport); json.field("size", contentLength); json.field("duration", latency); json.field("year", nowdt.toString("yyyy")); json.field("month", nowdt.toString("MM")); json.field("day", nowdt.toString("dd")); json.field("hour", nowdt.toString("HH")); json.field("minute", nowdt.toString("mm")); json.field("dow", nowdt.toString("EEE")); json.field("cluster", clusterName); if (remoteuser != null) { } catch (IOException e) { logger.info("## Could not serialize to json: {} {} {} {} {} {} {} {} [{}]", nowdt.toDateTimeISO().toString(), method, path,
dateAgg.extendedBounds((Long) bounds.getMin(), (Long) bounds.getMax()); } else if (bounds.getMinMaxType().isAssignableFrom(Date.class)) { dateAgg.extendedBounds(new DateTime(bounds.getMin()), new DateTime(bounds.getMax())); } else if (bounds.getMinMaxType().isAssignableFrom(String.class)) { dateAgg.extendedBounds((String) bounds.getMin(), (String) bounds.getMax());
@Override public RestResponse buildResponse(ConsistencyCheckResponse response) throws Exception { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.startObject(); builder.field("ok", true); builder.startObject("state"); response.getState().toXContent(builder, ToXContent.EMPTY_PARAMS); builder.startArray("files"); for (File file : response.getFiles()) { Instant instant = new Instant(file.lastModified()); builder.startObject() .field("path", file.getAbsolutePath()) .field("lastmodified", instant.toDateTime().toString()) .field("size", new SizeValue(file.length(), SizeUnit.SINGLE).toString()) .field("totalspace", new SizeValue(file.getTotalSpace(), SizeUnit.SINGLE).toString()) .field("usablespace", new SizeValue(file.getUsableSpace(), SizeUnit.SINGLE).toString()) .field("freespace", new SizeValue(file.getFreeSpace(), SizeUnit.SINGLE).toString()) .endObject(); } builder.endArray(); builder.endObject(); return new BytesRestResponse(OK, builder); } });
public static Date getFormattedDate(final String dateString) { return searchDateFormat.parseDateTime(dateString).toDate(); }
/** * Parse ISO datetime string. * * @param dateString to parse * @return parsed date * @throws IllegalArgumentException if date is not parseable */ public static final Date parseISODateTime(String dateString) { if (Utils.isEmpty(dateString)) return null; return ISODateTimeFormat.dateTimeParser().parseDateTime(dateString).toDate(); }
DateHistogram h = (DateHistogram) agg; for (DateHistogram.Bucket b : h.getBuckets()) { List<MultiBucketsAggregation.Bucket> l = bucketsByKey.get(b.getKeyAsDate().toDate()); if (l == null) { l = new ArrayList<>();
/** * Parse date string with minute precise - so seconds and milliseconds are set to 0. Used because JQL allows only * minute precise queries. * * @param dateString to parse * @return parsed date rounded to minute precise * @throws IllegalArgumentException if date is not parseable */ public static Date parseISODateTimeWithMinutePrecise(String dateString) { if (Utils.isEmpty(dateString)) return null; return DateTimeUtils.roundDateTimeToMinutePrecise(ISODateTimeFormat.dateTimeParser().parseDateTime(dateString) .toDate()); }
@Override public HistogramResult getHistogramResults(String name) { List<HistogramBucket> buckets = new ArrayList<HistogramBucket>(); Aggregation agg = this.searchResponse.getAggregations().get(name); if (agg == null) { return null; } if (agg instanceof DateHistogram) { DateHistogram h = (DateHistogram) agg; for (DateHistogram.Bucket b : h.getBuckets()) { buckets.add(new HistogramBucket(b.getKeyAsDate().toDate(), b.getDocCount())); } } else if (agg instanceof Histogram) { Histogram h = (Histogram) agg; for (Histogram.Bucket b : h.getBuckets()) { buckets.add(new HistogramBucket(b.getKey(), b.getDocCount())); } } else { throw new VertexiumException("Aggregation is not a histogram: " + agg.getClass().getName()); } return new HistogramResult(buckets); }
@Override public HistogramResult getHistogramResults(String name) { List<HistogramBucket> buckets = new ArrayList<HistogramBucket>(); Aggregation agg = this.searchResponse.getAggregations().get(name); if (agg == null) { return null; } if (agg instanceof DateHistogram) { DateHistogram h = (DateHistogram) agg; for (DateHistogram.Bucket b : h.getBuckets()) { buckets.add(new HistogramBucket(b.getKeyAsDate().toDate(), b.getDocCount())); } } else if (agg instanceof Histogram) { Histogram h = (Histogram) agg; for (Histogram.Bucket b : h.getBuckets()) { buckets.add(new HistogramBucket(b.getKey(), b.getDocCount())); } } else { throw new SecureGraphException("Aggregation is not a histogram: " + agg.getClass().getName()); } return new HistogramResult(buckets); }
@Override public HistogramResult getHistogramResults(String name) { List<HistogramBucket> buckets = new ArrayList<HistogramBucket>(); Aggregation agg = this.searchResponse.getAggregations().get(name); if (agg == null) { return null; } if (agg instanceof DateHistogram) { DateHistogram h = (DateHistogram) agg; for (DateHistogram.Bucket b : h.getBuckets()) { buckets.add(new HistogramBucket(b.getKeyAsDate().toDate(), b.getDocCount())); } } else if (agg instanceof Histogram) { Histogram h = (Histogram) agg; for (Histogram.Bucket b : h.getBuckets()) { buckets.add(new HistogramBucket(b.getKey(), b.getDocCount())); } } else { throw new SecureGraphException("Aggregation is not a histogram: " + agg.getClass().getName()); } return new HistogramResult(buckets); }