@Override public long applyAsLong(OffsetDateTime dt) { return dt.toInstant().toEpochMilli(); } },
public static String dateToRelative(OffsetDateTime data) { long time = data.toInstant().toEpochMilli(); long now = System.currentTimeMillis(); return DateUtils.getRelativeTimeSpanString(time, now, DateUtils.MINUTE_IN_MILLIS) .toString(); }
public void doLoadMore() { mPresenter.doLoadMore(mAdapter.getItem(mAdapter.getItemCount() - 2).getFormattedPublishDate().toInstant().toEpochMilli()); }
public void doLoadMore() { mPresenter.doLoadMore(mNewsType, mAdapter.getItem(mAdapter.getItemCount() - 2).getFormattedPublishDate().toInstant().toEpochMilli()); }
/** Returns TAI milliseconds mod 2^32 for the given date. * * Since java int is signed 32 bit integer, return long instead. * It is the same on byte level, but just to avoid confusing people with negative values here. * * * From http://stjarnhimlen.se/comp/time.html: * * TAI (Temps Atomique International or International Atomic Time) is * defined as the weighted average of the time kept by about 200 * atomic clocks in over 50 national laboratories worldwide. * TAI-UT1 was approximately 0 on 1958 Jan 1. * (TAI is ahead of UTC by 35 seconds as of 2014.) * * GPS time = TAI - 19 seconds. GPS time matched UTC from 1980-01-01 * to 1981-07-01. No leap seconds are inserted into GPS time, thus * GPS time is 13 seconds ahead of UTC on 2000-01-01. The GPS epoch * is 00:00 (midnight) UTC on 1980-01-06. * The difference between GPS Time and UTC changes in increments of * seconds each time a leap second is added to UTC time scale. */ public static long instantToTaiMillisSince2004Mod32(Instant instantX) { OffsetDateTime gnEpochStart = OffsetDateTime.of(LocalDateTime.of(2004, Month.JANUARY, 1, 0, 0), ZoneOffset.UTC); long millis2004 = gnEpochStart.toInstant().toEpochMilli(); long millisAtX = instantX.toEpochMilli(); long taiMillis = (millisAtX + LEAP_SECONDS_SINCE_2004*1000) - millis2004; return taiMillis % (1L << 32); }
@Override public LongPositionVector getLatestPosition() { Optional<Address> emptyAddress = Optional.empty(); if (lastSeenTPV == null) { Instant timestamp = Instant.now(); Position position = new Position(Double.NaN, Double.NaN); // NaN or 0? boolean isPositionConfident = false; double speedMetersPerSecond = 0; double headingDegreesFromNorth = 0; return new LongPositionVector(emptyAddress, timestamp, position, isPositionConfident, speedMetersPerSecond, headingDegreesFromNorth); } else { final TPV tpv = lastSeenTPV; // Is this enough to ensure that tpv will remain the same // through the rest of the method? Instant timestamp = OffsetDateTime.parse(tpv.time()).toInstant(); Position position = new Position(tpv.lat(), tpv.lon()); boolean isPositionConfident = false; // TODO: double-check conditions for PAI=true. double speedMetersPerSecond = tpv.speed(); double headingDegreesFromNorth = tpv.track(); return new LongPositionVector(emptyAddress, timestamp, position, isPositionConfident, speedMetersPerSecond, headingDegreesFromNorth); } }