本文整理了Java中java.time.zone.ZoneOffsetTransition.getDateTimeAfter()
方法的一些代码示例,展示了ZoneOffsetTransition.getDateTimeAfter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOffsetTransition.getDateTimeAfter()
方法的具体详情如下:
包路径:java.time.zone.ZoneOffsetTransition
类名称:ZoneOffsetTransition
方法名:getDateTimeAfter
[英]Gets the local transition date-time, as would be expressed with the 'after' offset.
This is the first date-time after the discontinuity, when the new offset applies.
The combination of the 'before' date-time and offset represents the same instant as the 'after' date-time and offset.
[中]获取本地转换日期时间,用“after”偏移量表示。
这是不连续之后的第一个日期时间,此时将应用新的偏移。
“之前”日期时间和偏移量的组合表示与“之后”日期时间和偏移量相同的时刻。
代码示例来源:origin: com.github.seratch/java-time-backport
if (trans.isGap()) {
localTransitionList.add(trans.getDateTimeBefore());
localTransitionList.add(trans.getDateTimeAfter());
} else {
localTransitionList.add(trans.getDateTimeAfter());
localTransitionList.add(trans.getDateTimeBefore());
代码示例来源:origin: com.github.seratch/java-time-backport
if (trans.isGap()) {
localTransitionList.add(trans.getDateTimeBefore());
localTransitionList.add(trans.getDateTimeAfter());
} else {
localTransitionList.add(trans.getDateTimeAfter());
localTransitionList.add(trans.getDateTimeBefore());
代码示例来源:origin: com.addthis/cronus
/**
* If there is no daylight savings time transition
* the ignore any effects of daylight savings and return
* the local output time.
*
* If there is a daylight savings time overlap transition
* (the clocks are set back) then select the time zone
* offset from before the transition.
*
* If there is a daylight saving time gap transition
* (the clocks are set forward) then we cannot use the local
* output time because it is not a legal time value.
* Move the event to the end of the transition.
*/
private ZonedDateTime outputAdjustDaylightSavings(LocalDateTime output, ZoneId zoneId) {
if (output == null) {
return null;
}
ZoneRules zoneRules = zoneId.getRules();
ZoneOffsetTransition transition = zoneRules.getTransition(output);
if (transition == null) {
return ZonedDateTime.of(output, zoneId);
} else if (transition.isOverlap()) {
return ZonedDateTime.ofInstant(output, transition.getOffsetBefore(), zoneId);
} else {
return ZonedDateTime.ofInstant(transition.getDateTimeAfter(), transition.getOffsetAfter(), zoneId);
}
}
代码示例来源:origin: com.github.seratch/java-time-backport
ZoneOffsetTransition trans = rules.getTransition(ldt);
if (trans != null && trans.isGap()) {
ldt = trans.getDateTimeAfter();
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Finds the offset info for a local date-time and transition.
*
* @param dt the date-time, not null
* @param trans the transition, not null
* @return the offset info, not null
*/
private Object findOffsetInfo(LocalDateTime dt, ZoneOffsetTransition trans) {
LocalDateTime localTransition = trans.getDateTimeBefore();
if (trans.isGap()) {
if (dt.isBefore(localTransition)) {
return trans.getOffsetBefore();
}
if (dt.isBefore(trans.getDateTimeAfter())) {
return trans;
} else {
return trans.getOffsetAfter();
}
} else {
if (dt.isBefore(localTransition) == false) {
return trans.getOffsetAfter();
}
if (dt.isBefore(trans.getDateTimeAfter())) {
return trans.getOffsetBefore();
} else {
return trans;
}
}
}
代码示例来源:origin: infiniteautomation/ma-core-public
/**
* @param zdt
* @return
*/
public Instant getInstant(ZonedDateTime zdt) {
ZonedDateTime offset = zdt.withHour(hour).withMinute(minute).withSecond(second).withNano((int)(millisecond * 1000000l));
LocalDateTime ldt = zdt.toLocalDateTime();
ldt = ldt.withHour(hour).withMinute(minute).withSecond(second).withNano((int)(millisecond * 1000000l));
if(!zdt.getZone().getRules().isValidOffset(ldt, zdt.getOffset())) {
//Within a gap of DST so OR after the transition
ZoneOffsetTransition transition = zdt.getZone().getRules().nextTransition(zdt.toInstant());
if(!ldt.isAfter(transition.getDateTimeAfter())){
//In a gap so we shift our time forward to the end of the gap.
offset = transition.getDateTimeAfter().atZone(zdt.getZone());
}else {
//After a gap so ensure we use the next zone offset
offset = ldt.atOffset(transition.getOffsetAfter()).atZoneSimilarLocal(transition.getOffsetAfter());
}
}
return offset.toInstant();
}
}
内容来源于网络,如有侵权,请联系作者删除!