/** {@inheritDoc} */ @Override public long getStartTime() { return statMgr.startTime().toEpochSecond(); }
private static EventDateTime getEventDateTime(CalendarEventModel.CalendarEventTime dateTime) { if (dateTime == null) { return null; } EventDateTime eventDateTime = new EventDateTime(); // google's APIs want millisecond from epoch, and the timezone offset in minutes. if (dateTime.isDateOnly()) { eventDateTime.setDate(new DateTime(true, dateTime.getDateTime().toEpochSecond() * 1000, dateTime.getDateTime().getOffset().getTotalSeconds() / 60)); } else { eventDateTime.setDateTime(new DateTime( dateTime.getDateTime().toEpochSecond() * 1000, dateTime.getDateTime().getOffset().getTotalSeconds() / 60)); } return eventDateTime; }
Assert.assertEquals(ioStatMgr.startTime().toEpochSecond(), bean.getStartTime()); Assert.assertEquals(ioStatMgr.startTime().toEpochSecond(), bean.getStartTime());
/** * Simple test JMX bean for caches IO stats. * * @throws Exception In case of failure. */ @Test public void testCacheBasic() throws Exception { IoStatisticsMetricsMXBean bean = ioStatMXBean(); IoStatisticsManager ioStatMgr = ignite.context().ioStats(); Assert.assertEquals(ioStatMgr.startTime().toEpochSecond(), bean.getStartTime()); Assert.assertEquals(ioStatMgr.startTime().format(DateTimeFormatter.ISO_DATE_TIME), bean.getStartTimeLocal()); bean.reset(); Assert.assertEquals(ioStatMgr.startTime().toEpochSecond(), bean.getStartTime()); Assert.assertEquals(ioStatMgr.startTime().format(DateTimeFormatter.ISO_DATE_TIME), bean.getStartTimeLocal()); int cnt = 100; warmUpMemmory(bean, cnt); populateCache(cnt); Long cacheLogicalReadsCnt = bean.getCacheGroupLogicalReads(DEFAULT_CACHE_NAME); Assert.assertNotNull(cacheLogicalReadsCnt); Assert.assertEquals(cnt, cacheLogicalReadsCnt.longValue()); Long cachePhysicalReadsCnt = bean.getCacheGroupPhysicalReads(DEFAULT_CACHE_NAME); Assert.assertNotNull(cachePhysicalReadsCnt); Assert.assertEquals(0, cachePhysicalReadsCnt.longValue()); String formatted = bean.getCacheGroupStatistics(DEFAULT_CACHE_NAME); Assert.assertEquals("CACHE_GROUP default [LOGICAL_READS=100, PHYSICAL_READS=0]", formatted); String unexistedStats = bean.getCacheGroupStatistics("unknownCache"); Assert.assertEquals("CACHE_GROUP unknownCache []", unexistedStats); }
@Override protected String toJsonNanos(OffsetDateTime value) { return toJsonNanos(value.toEpochSecond(), value.getNano()); }
@Override public Timestamp toNonNullValue(OffsetDateTime value) { final Timestamp timestamp = new Timestamp((value.toEpochSecond() * MILLIS_IN_SECOND)); timestamp.setNanos(value.getNano()); return timestamp; }
@Override public Timestamp toNonNullValue(OffsetDateTime value) { final Timestamp timestamp = new Timestamp((value.toEpochSecond() * MILLIS_IN_SECOND)); timestamp.setNanos(value.getNano()); return timestamp; }
public static CalendarDate valueOf(OffsetDateTime offsetDateTime) { return new CalendarDate(offsetDateTime.toEpochSecond() * MILLIS_PER_SECOND); }
public static CalendarDate valueOf(OffsetDateTime offsetDateTime) { return new CalendarDate(offsetDateTime.toEpochSecond() * MILLIS_PER_SECOND); }
@Override public Timestamp toNonNullValue(OffsetTime value) { OffsetDateTime odt = value.atDate(LocalDate.of(1970, 1, 1)); final Timestamp timestamp = new Timestamp((odt.toEpochSecond() * MILLIS_IN_SECOND)); timestamp.setNanos(value.getNano()); return timestamp; }
@Override public Timestamp toNonNullValue(OffsetTime value) { OffsetDateTime odt = value.atDate(LocalDate.of(1970, 1, 1)); final Timestamp timestamp = new Timestamp((odt.toEpochSecond() * MILLIS_IN_SECOND)); timestamp.setNanos(value.getNano()); return timestamp; }
/** * Converts the given OffsetDateTime to a Timestamp. * * @param offsetDateTime * the OffsetDateTime to convert * @return Timestamp object that is equivalent to the given OffsetDateTime. */ private static Timestamp toTimestamp(OffsetDateTime offsetDateTime) { long seconds = offsetDateTime.toEpochSecond(); int nanos = offsetDateTime.getNano(); long microseconds = TimeUnit.SECONDS.toMicros(seconds) + TimeUnit.NANOSECONDS.toMicros(nanos); return Timestamp.ofTimeMicroseconds(microseconds); }
@Override public int compare(OffsetDateTime datetime1, OffsetDateTime datetime2) { int cmp = Jdk8Methods.compareLongs(datetime1.toEpochSecond(), datetime2.toEpochSecond()); if (cmp == 0) { cmp = Jdk8Methods.compareLongs(datetime1.getNano(), datetime2.getNano()); } return cmp; } };
@Override protected String toJsonNanos(OffsetDateTime value) { return toJsonNanos(value.toEpochSecond(), value.getNano()); }
@Override protected String toJsonNanos(OffsetDateTime value) { return toJsonNanos(value.toEpochSecond(), value.getNano()); }
/** * Checks if the instant of this date-time is after that of the specified date-time. * <p> * This method differs from the comparison in {@link #compareTo} and {@link #equals} in that it * only compares the instant of the date-time. This is equivalent to using * {@code dateTime1.toInstant().isAfter(dateTime2.toInstant());}. * * @param other the other date-time to compare to, not null * @return true if this is after the instant of the specified date-time */ public boolean isAfter(OffsetDateTime other) { long thisEpochSec = toEpochSecond(); long otherEpochSec = other.toEpochSecond(); return thisEpochSec > otherEpochSec || (thisEpochSec == otherEpochSec && toLocalTime().getNano() > other.toLocalTime().getNano()); }
/** * Checks if the instant of this date-time is equal to that of the specified date-time. * <p> * This method differs from the comparison in {@link #compareTo} and {@link #equals} * in that it only compares the instant of the date-time. This is equivalent to using * {@code dateTime1.toInstant().equals(dateTime2.toInstant());}. * * @param other the other date-time to compare to, not null * @return true if the instant equals the instant of the specified date-time */ public boolean isEqual(OffsetDateTime other) { return toEpochSecond() == other.toEpochSecond() && toLocalTime().getNano() == other.toLocalTime().getNano(); }
@Override public ValueBuilder<?, ?, ?> toDatastore(Object input) { if (input == null) { return NullValue.newBuilder(); } OffsetDateTime offsetDateTime = (OffsetDateTime) input; long seconds = offsetDateTime.toEpochSecond(); int nanos = offsetDateTime.getNano(); long microseconds = TimeUnit.SECONDS.toMicros(seconds) + TimeUnit.NANOSECONDS.toMicros(nanos); return TimestampValue.newBuilder(Timestamp.ofTimeMicroseconds(microseconds)); }
@Test public void get() throws SQLException { ResultSet resultSet = EasyMock.createNiceMock(ResultSet.class); EasyMock.expect(resultSet.getTimestamp(1, UTC)).andReturn(new Timestamp(UTC.getTimeInMillis())); EasyMock.replay(resultSet); OffsetDateTime result = type.getValue(resultSet, 1); EasyMock.verify(resultSet); assertNotNull(result); assertTrue(result.toEpochSecond() == 0); } }
public static LocalDateTime toLocalDateTimeInZone(OffsetDateTime dateTime, ZoneId zoneId) { return LocalDateTime.ofEpochSecond(dateTime.toEpochSecond(), dateTime.getNano(), zoneId.getRules().getOffset(dateTime.toInstant())); }