本文整理了Java中java.time.zone.ZoneOffsetTransition.toEpochSecond()
方法的一些代码示例,展示了ZoneOffsetTransition.toEpochSecond()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOffsetTransition.toEpochSecond()
方法的具体详情如下:
包路径:java.time.zone.ZoneOffsetTransition
类名称:ZoneOffsetTransition
方法名:toEpochSecond
[英]Gets the transition instant as an epoch second.
[中]以秒为单位获取转换瞬间。
代码示例来源:origin: io.airlift/joda-to-java-time-bridge
@Override
public long previousTransition(long instant)
{
// +1 and -1 is necessary here because java.time API expects/returns ......00000 for previousTransition,
// whereas joda API expects/returns ......99999 for previousTransition.
// This adjustment is only needed for previousTransition because both expects/returns ......00000 for nextTransitions.
ZoneOffsetTransition previousTransition = zoneRules.previousTransition(Instant.ofEpochMilli(instant + 1));
if (previousTransition == null) {
// this is before the first transition
return instant;
}
return previousTransition.toEpochSecond() * 1000 - 1;
}
代码示例来源:origin: io.airlift/joda-to-java-time-bridge
@Override
public long nextTransition(long instant)
{
ZoneOffsetTransition nextTransition = zoneRules.nextTransition(Instant.ofEpochMilli(instant));
if (nextTransition == null) {
// this is after the last transition
return instant;
}
return nextTransition.toEpochSecond() * 1000;
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Writes the state to the stream.
*
* @param out the output stream, not null
* @throws IOException if an error occurs
*/
void writeExternal(DataOutput out) throws IOException {
Ser.writeEpochSec(toEpochSecond(), out);
Ser.writeOffset(offsetBefore, out);
Ser.writeOffset(offsetAfter, out);
}
代码示例来源:origin: com.github.seratch/java-time-backport
this.standardOffsets[0] = baseStandardOffset;
for (int i = 0; i < standardOffsetTransitionList.size(); i++) {
this.standardTransitions[i] = standardOffsetTransitionList.get(i).toEpochSecond();
this.standardOffsets[i + 1] = standardOffsetTransitionList.get(i).getOffsetAfter();
代码示例来源:origin: com.github.seratch/java-time-backport
@Override
public ZoneOffset getOffset(Instant instant) {
long epochSec = instant.getEpochSecond();
// check if using last rules
if (lastRules.length > 0 &&
epochSec > savingsInstantTransitions[savingsInstantTransitions.length - 1]) {
int year = findYear(epochSec, wallOffsets[wallOffsets.length - 1]);
ZoneOffsetTransition[] transArray = findTransitionArray(year);
ZoneOffsetTransition trans = null;
for (int i = 0; i < transArray.length; i++) {
trans = transArray[i];
if (epochSec < trans.toEpochSecond()) {
return trans.getOffsetBefore();
}
}
return trans.getOffsetAfter();
}
// using historic rules
int index = Arrays.binarySearch(savingsInstantTransitions, epochSec);
if (index < 0) {
// switch negative insert position to start of matched range
index = -index - 2;
}
return wallOffsets[index + 1];
}
代码示例来源:origin: com.github.seratch/java-time-backport
ZoneOffsetTransition[] transArray = findTransitionArray(year);
for (ZoneOffsetTransition trans : transArray) {
if (epochSec < trans.toEpochSecond()) {
return trans;
代码示例来源:origin: com.github.seratch/java-time-backport
ZoneOffsetTransition[] transArray = findTransitionArray(year);
for (int i = transArray.length - 1; i >= 0; i--) {
if (epochSec > transArray[i].toEpochSecond()) {
return transArray[i];
代码示例来源:origin: com.github.seratch/java-time-backport
for (TZRule rule : window.ruleList) {
ZoneOffsetTransition trans = rule.toTransition(loopStandardOffset, loopSavings);
if (trans.toEpochSecond() > loopWindowStart.toEpochSecond(loopWindowOffset)) {
if (trans.toEpochSecond() < loopWindowStart.toEpochSecond(loopWindowOffset) == false &&
trans.toEpochSecond() < window.createDateTimeEpochSecond(loopSavings) &&
trans.getOffsetBefore().equals(trans.getOffsetAfter()) == false) {
transitionList.add(trans);
内容来源于网络,如有侵权,请联系作者删除!