- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中java.time.zone.ZoneOffsetTransition
类的一些代码示例,展示了ZoneOffsetTransition
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOffsetTransition
类的具体详情如下:
包路径:java.time.zone.ZoneOffsetTransition
类名称:ZoneOffsetTransition
[英]A transition between two offsets caused by a discontinuity in the local time-line.
A transition between two offsets is normally the result of a daylight savings cutover. The discontinuity is normally a gap in spring and an overlap in autumn. ZoneOffsetTransition models the transition between the two offsets.
Gaps occur where there are local date-times that simply do not not exist. An example would be when the offset changes from +03:00 to +04:00. This might be described as 'the clocks will move forward one hour tonight at 1am'.
Overlaps occur where there are local date-times that exist twice. An example would be when the offset changes from +04:00 to +03:00. This might be described as 'the clocks will move back one hour tonight at 2am'.
This class is immutable and thread-safe.
[中]由当地时间线的不连续性引起的两个偏移之间的过渡。
两个偏移之间的过渡通常是夏令时切换的结果。这种不连续性通常是春季的一个间隙,秋季的一个重叠。ZoneOffsetTransition为两个偏移之间的过渡建模。
当本地日期时间根本不存在时,就会出现间隔。例如,偏移从+03:00更改为+04:00。这可能被描述为“时钟将在今晚凌晨1点向前移动一小时”。
如果存在两次本地日期时间,则会发生重叠。例如,偏移从+04:00更改为+03:00。这可以被描述为“今晚凌晨2点钟会向后拨一小时”。
####实施者规范
这个类是不可变的,是线程安全的。
代码示例来源: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: 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();
localTransitionOffsetList.add(baseWallOffset);
for (ZoneOffsetTransition trans : transitionList) {
if (trans.isGap()) {
localTransitionList.add(trans.getDateTimeBefore());
localTransitionList.add(trans.getDateTimeAfter());
} else {
localTransitionList.add(trans.getDateTimeAfter());
localTransitionList.add(trans.getDateTimeBefore());
localTransitionOffsetList.add(trans.getOffsetAfter());
this.savingsInstantTransitions[i] = transitionList.get(i).getInstant().getEpochSecond();
代码示例来源:origin: com.vaadin/vaadin-server
break;
i = t.getInstant().atZone(zoneId);
if (i.toLocalDate().getYear() != year) {
break;
.ofSeconds(t.getInstant().getEpochSecond())
.toHours();
long duration = Math.max(t.getDuration().toMinutes(), 0);
transitionsList.add(epochHours);
transitionsList.add(duration);
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Gets the valid offsets during this transition.
* <p>
* A gap will return an empty list, while an overlap will return both offsets.
*
* @return the list of valid offsets
*/
List<ZoneOffset> getValidOffsets() {
if (isGap()) {
return Collections.emptyList();
}
return Arrays.asList(getOffsetBefore(), getOffsetAfter());
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Does this transition represent a gap in the local time-line.
* <p>
* Gaps occur where there are local date-times that simply do not not exist.
* An example would be when the offset changes from {@code +01:00} to {@code +02:00}.
* This might be described as 'the clocks will move forward one hour tonight at 1am'.
*
* @return true if this transition is a gap, false if it is an overlap
*/
public boolean isGap() {
return getOffsetAfter().getTotalSeconds() > getOffsetBefore().getTotalSeconds();
}
代码示例来源:origin: ical4j/ical4j
private static void addTransitions(ZoneId zoneId, VTimeZone result, int rawTimeZoneOffsetInSeconds) throws ParseException {
Map<ZoneOffsetKey, Set<ZoneOffsetTransition>> zoneTransitionsByOffsets = new HashMap<ZoneOffsetKey, Set<ZoneOffsetTransition>>();
for (ZoneOffsetTransition zoneTransitionRule : zoneId.getRules().getTransitions()) {
ZoneOffsetKey offfsetKey = ZoneOffsetKey.of(zoneTransitionRule.getOffsetBefore(), zoneTransitionRule.getOffsetAfter());
Set<ZoneOffsetTransition> transitionRulesForOffset = zoneTransitionsByOffsets.computeIfAbsent(offfsetKey, k -> new HashSet<ZoneOffsetTransition>(1));
transitionRulesForOffset.add(zoneTransitionRule);
}
for (Map.Entry<ZoneOffsetKey, Set<ZoneOffsetTransition>> e : zoneTransitionsByOffsets.entrySet()) {
Observance observance = (e.getKey().offsetAfter.getTotalSeconds() > rawTimeZoneOffsetInSeconds) ? new Daylight() : new Standard();
LocalDateTime start = Collections.min(e.getValue()).getDateTimeBefore();
DtStart dtStart = new DtStart(start.format(DateTimeFormatter.ofPattern(DATE_TIME_TPL)));
TzOffsetFrom offsetFrom = new TzOffsetFrom(e.getKey().offsetBefore);
TzOffsetTo offsetTo = new TzOffsetTo(e.getKey().offsetAfter);
observance.getProperties().add(dtStart);
observance.getProperties().add(offsetFrom);
observance.getProperties().add(offsetTo);
for (ZoneOffsetTransition transition : e.getValue()) {
RDate rDate = new RDate(new ParameterList(), transition.getDateTimeBefore().format(DateTimeFormatter.ofPattern(DATE_TIME_TPL)));
observance.getProperties().add(rDate);
}
result.getObservances().add(observance);
}
}
代码示例来源: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
for (TZRule rule : window.ruleList) {
ZoneOffsetTransition trans = rule.toTransition(loopStandardOffset, loopSavings);
if (trans.toEpochSecond() > loopWindowStart.toEpochSecond(loopWindowOffset)) {
new ZoneOffsetTransition(
LocalDateTime.ofEpochSecond(loopWindowStart.toEpochSecond(loopWindowOffset), 0, loopStandardOffset),
loopStandardOffset, window.standardOffset)));
if (loopWindowOffset.equals(effectiveWallOffset) == false) {
ZoneOffsetTransition trans = deduplicate(
new ZoneOffsetTransition(loopWindowStart, loopWindowOffset, effectiveWallOffset));
transitionList.add(trans);
if (trans.toEpochSecond() < loopWindowStart.toEpochSecond(loopWindowOffset) == false &&
trans.toEpochSecond() < window.createDateTimeEpochSecond(loopSavings) &&
trans.getOffsetBefore().equals(trans.getOffsetAfter()) == false) {
transitionList.add(trans);
loopSavings = rule.savingAmountSecs;
代码示例来源: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: net.time4j/time4j-olson
Instant instant = zot.getInstant();
long posixTime = instant.getEpochSecond();
int previousOffset = zot.getOffsetBefore().getTotalSeconds();
int totalOffset = zot.getOffsetAfter().getTotalSeconds();
int dst = Math.toIntExact(zoneRules.getDaylightSavings(instant).getSeconds());
transitions.add(new ZonalTransition(posixTime, previousOffset, totalOffset, dst));
代码示例来源:origin: com.github.seratch/java-time-backport
ZoneOffset before = wallOffsets[i];
ZoneOffset after = wallOffsets[i + 1];
ZoneOffsetTransition trans = new ZoneOffsetTransition(savingsInstantTransitions[i], before, after);
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
} else if (validOffsets.size() == 0) {
ZoneOffsetTransition trans = rules.getTransition(isoLDT);
localDateTime = localDateTime.plusSeconds(trans.getDuration().getSeconds());
offset = trans.getOffsetAfter();
} else {
if (preferredOffset != null && validOffsets.contains(preferredOffset)) {
代码示例来源:origin: com.github.seratch/java-time-backport
@Override
public ChronoZonedDateTime<D> withEarlierOffsetAtOverlap() {
ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
if (trans != null && trans.isOverlap()) {
ZoneOffset earlierOffset = trans.getOffsetBefore();
if (earlierOffset.equals(offset) == false) {
return new ChronoZonedDateTimeImpl<D>(dateTime, earlierOffset, zone);
}
}
return this;
}
代码示例来源:origin: com.addthis/cronus
/**
* If we are in the duplicated time period of an overlap transition,
* then move forwards around the duplicated time period.
*/
private ZonedDateTime inputDaylightSavingsNext(ZonedDateTime input) {
ZoneId zoneId = input.getZone();
ZoneRules zoneRules = zoneId.getRules();
ZoneOffset zoneOffset = input.getOffset();
LocalDateTime localDateTime = input.toLocalDateTime();
ZoneOffsetTransition transition = zoneRules.getTransition(localDateTime);
if (transition == null) {
return input;
} else if (zoneOffset.equals(transition.getOffsetAfter())) {
return ZonedDateTime.ofInstant(transition.getDateTimeBefore(),
transition.getOffsetAfter(), zoneId);
} else {
return input;
}
}
代码示例来源: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();
}
}
代码示例来源:origin: com.github.seratch/java-time-backport
@Override
public ChronoZonedDateTime<D> withLaterOffsetAtOverlap() {
ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
if (trans != null) {
ZoneOffset offset = trans.getOffsetAfter();
if (offset.equals(getOffset()) == false) {
return new ChronoZonedDateTimeImpl<D>(dateTime, offset, zone);
}
}
return this;
}
代码示例来源:origin: com.github.seratch/java-time-backport
for (ZoneOffsetTransition trans : transArray) {
info = findOffsetInfo(dt, trans);
if (info instanceof ZoneOffsetTransition || info.equals(trans.getOffsetBefore())) {
return info;
if (offsetAfter.getTotalSeconds() > offsetBefore.getTotalSeconds()) {
return new ZoneOffsetTransition(dtBefore, offsetBefore, offsetAfter);
} else {
return new ZoneOffsetTransition(dtAfter, offsetBefore, offsetAfter);
代码示例来源:origin: com.github.seratch/java-time-backport
ZoneRules rules = zone.getRules();
ZoneOffsetTransition trans = rules.getTransition(ldt);
if (trans != null && trans.isGap()) {
ldt = trans.getDateTimeAfter();
代码示例来源:origin: com.github.seratch/java-time-backport
ZoneOffsetTransition[] transArray = findTransitionArray(year);
for (ZoneOffsetTransition trans : transArray) {
if (epochSec < trans.toEpochSecond()) {
return trans;
index += 1; // exact match, so need to add one to get the next
return new ZoneOffsetTransition(savingsInstantTransitions[index], wallOffsets[index], wallOffsets[index + 1]);
代码示例来源:origin: ical4j/ical4j
startDate = zoneOffsetTransition.getDateTimeBefore();
} else {
startDate = LocalDateTime.now(zoneId);
在尝试 time 的 python 执行时,我发现在一条语句中两次调用 time.time() 时出现奇怪的行为。在语句执行期间获取time.time() 有一个非常小的处理延迟。 例如time.ti
我要疯了。对于我的生活,我无法弄清楚为什么以下代码会导致 Unity 在我按下播放键后立即卡住。这是一个空的项目,脚本附加到一个空的游戏对象。在控制台中,什么也没有出现,甚至没有出现初始的 Debug
我要疯了。对于我的生活,我无法弄清楚为什么以下代码会导致 Unity 在我按下播放键后立即卡住。这是一个空的项目,脚本附加到一个空的游戏对象。在控制台中,什么也没有出现,甚至没有出现初始的 Debug
我不明白为什么下面的结果是一样的。我预计第一个结果是指针地址。 func print(t *time.Time) { fmt.Println(t) // 2009-11-10 23:00:00
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32 Type "help
当我有一个time.Time时: // January, 29th t, _ := time.Parse("2006-01-02", "2016-01-29") 如何获得代表 1 月 31 日的 ti
首先,我意识到不推荐使用 time with time zone。我要使用它是因为我将多个 time with time zone 值与我当前的系统时间进行比较,而不管是哪一天。 IE。用户说每天 0
长期以来,在 Rust 中精确测量时间的标准方法是 time crate 及其 time::precise_time_ns功能。但是,time crate 现在已被弃用,std 库有 std::tim
我正在我学校的一个科学集群上运行我的有限差分程序。该程序使用 openmpi 来并行化代码。 当程序连续运行时,我得到: real 78m40.592s user 78m34.920s s
尽管它们已被弃用并且有比 time 更好的模块(即 timeit),但我想知道这两个函数 time 之间的区别.clock() 和 time.time()。 从后者 (time.time()) 开始,
这个问题在这里已经有了答案: Python's time.clock() vs. time.time() accuracy? (16 个答案) 关闭 6 年前。 我认为两者都衡量时间量?但是他们返回
我正在尝试测试 http 请求处理代码块在我的 Flask Controller 中需要多长时间,这是我使用的示例代码: cancelled = [] t0 = time.time() t1 = ti
运行 python 的计算机时钟(Windows 或 Linux)时会发生什么自动更改并调用 time.time()? 我读到,当时钟手动更改为过去的某个值时,time.time() 的值会变小。 最
我有一个结构可能无法在其字段之一上设置 time.Time 值。测试无效性时,我不能使用 nil 或 0。time.Unix(0,0) 也不相同。我想到了这个: var emptyTime time.
我有一个打算用数据库记录填充的结构,其中一个日期时间列可以为空: type Reminder struct { Id int CreatedAt time.Time
问题陈述:通过匹配其百分比随机执行各种命令。比如执行 CommandA 50% 的时间和 commandB 25% 的时间和 commandC 15% 的时间等等,总百分比应该是 100%。 我的问题
我正在使用 laravel 6。我在同一个应用程序中有类似的 Controller 和类似的 View ,它工作正常。对比之后还是找不到错误。 Facade\Ignition\Exceptions\V
我需要用 ("%m/%d/%Y %H:%M:%S") 格式表示时间,我得到的浮点值是 time.time(). 我已经有了一个 time.time() 形式的值。例如,我已经有一个值,我每 0.3 秒
我正在使用以下方法获取 utc 日期时间: import datetime import time from pytz import timezone now_utc = datetime.datet
我在 Ubuntu 上使用 time.clock 和 time.time 为一段 python 代码计时: clock elapsed time: 8.770 s time elapsed time
我是一名优秀的程序员,十分优秀!