本文整理了Java中org.threeten.bp.OffsetDateTime.toInstant()
方法的一些代码示例,展示了OffsetDateTime.toInstant()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OffsetDateTime.toInstant()
方法的具体详情如下:
包路径:org.threeten.bp.OffsetDateTime
类名称:OffsetDateTime
方法名:toInstant
[英]Converts this date-time to an Instant.
[中]将此日期时间转换为瞬间。
代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp
@Override
public long applyAsLong(OffsetDateTime dt) {
return dt.toInstant().toEpochMilli();
}
},
代码示例来源:origin: gotify/android
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();
}
代码示例来源:origin: guanpj/JReadHub
public void doLoadMore() {
mPresenter.doLoadMore(mAdapter.getItem(mAdapter.getItemCount() - 2).getFormattedPublishDate().toInstant().toEpochMilli());
}
代码示例来源:origin: guanpj/JReadHub
public void doLoadMore() {
mPresenter.doLoadMore(mNewsType, mAdapter.getItem(mAdapter.getItemCount() - 2).getFormattedPublishDate().toInstant().toEpochMilli());
}
代码示例来源:origin: alexvoronov/geonetworking
/** 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);
}
代码示例来源:origin: alexvoronov/geonetworking
@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);
}
}
内容来源于网络,如有侵权,请联系作者删除!