List of usage examples for java.time LocalDateTime toEpochSecond
default long toEpochSecond(ZoneOffset offset)
From source file:Main.java
/** * @param date//from w w w . j a v a 2 s .c o m * Date for which seconds since the epoch date is to be calculated * @return Number of seconds after the unix epoch date equivalent to the given date */ public static Integer secondsSinceUnixEpoch(final LocalDateTime date) { if (date == null) { return null; } final Long timeInSeconds = Long.valueOf(date.toEpochSecond(ZoneOffset.UTC)); return Integer.valueOf(timeInSeconds.intValue()); }
From source file:io.pivotal.demo.smartgrid.frontend.timeseries.AggregateCounterTimeSeriesRepository.java
private TimeSeriesCollection convertToTimeSeriesCollection(AggregateCounterCollection acc) { TimeSeriesCollection tsc = new TimeSeriesCollection(acc.getName()); for (Map.Entry<String, AggregateCounter> entry : acc.getAggregateCounters().entrySet()) { String timeSeriesName = entry.getKey(); AggregateCounter aggregateCounter = entry.getValue(); List<String> timeAxis = new ArrayList<>(); List<String> valueAxis = new ArrayList<>(); for (Map.Entry<String, String> dataPoint : aggregateCounter.getCounts().entrySet()) { String pit = dataPoint.getKey(); String value = dataPoint.getValue(); LocalDateTime ldt = LocalDateTime.parse(pit, DateTimeFormatter.ISO_DATE_TIME); timeAxis.add("" + ldt.toEpochSecond(ZoneOffset.UTC)); valueAxis.add(value);//from w ww .j a v a 2 s. c o m } tsc.registerTimeSeries(timeSeriesName, timeAxis, valueAxis); } return tsc; }