本文整理了Java中java.time.zone.ZoneOffsetTransitionRule
类的一些代码示例,展示了ZoneOffsetTransitionRule
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOffsetTransitionRule
类的具体详情如下:
包路径:java.time.zone.ZoneOffsetTransitionRule
类名称:ZoneOffsetTransitionRule
[英]A rule expressing how to create a transition.
This class allows rules for identifying future transitions to be expressed. A rule might be written in many forms:
These different rule types can be expressed and queried.
This class is immutable and thread-safe.
[中]表示如何创建转换的规则。
此类允许表示用于标识未来转换的规则。规则可能有多种形式:
*3月16日
*3月16日当天或之后的星期日
*3月16日或之前的星期日
*二月的最后一个星期天
可以表达和查询这些不同的规则类型。
####实施者规范
这个类是不可变的,是线程安全的。
代码示例来源:origin: wildfly/wildfly
assertTrue(immutability.test(ZoneOffset.UTC));
assertTrue(immutability.test(ZoneRules.of(ZoneOffset.UTC).nextTransition(Instant.now())));
assertTrue(immutability.test(ZoneOffsetTransitionRule.of(Month.JANUARY, 1, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.STANDARD, ZoneOffset.UTC, ZoneOffset.ofHours(1), ZoneOffset.ofHours(2))));
assertTrue(immutability.test(ZoneRules.of(ZoneOffset.UTC)));
assertTrue(immutability.test(ZonedDateTime.now()));
代码示例来源:origin: bluestreak01/questdb
ZoneOffsetTransitionRule zr = lastRules[i];
TransitionRule tr = new TransitionRule();
tr.offsetBefore = zr.getOffsetBefore().getTotalSeconds();
tr.offsetAfter = zr.getOffsetAfter().getTotalSeconds();
tr.standardOffset = zr.getStandardOffset().getTotalSeconds();
tr.dow = zr.getDayOfWeek() == null ? -1 : zr.getDayOfWeek().getValue();
tr.dom = zr.getDayOfMonthIndicator();
tr.month = zr.getMonth().getValue();
tr.midnightEOD = zr.isMidnightEndOfDay();
tr.hour = zr.getLocalTime().getHour();
tr.minute = zr.getLocalTime().getMinute();
tr.second = zr.getLocalTime().getSecond();
switch (zr.getTimeDefinition()) {
case UTC:
tr.timeDef = TransitionRule.UTC;
代码示例来源:origin: org.mnode.ical4j/ical4j
int transitionRuleMonthValue = transitionRule.getMonth().getValue();
DayOfWeek transitionRuleDayOfWeek = transitionRule.getDayOfWeek();
LocalDateTime ldt = LocalDateTime.now(zoneId)
.with(TemporalAdjusters.firstInMonth(transitionRuleDayOfWeek))
.withMonth(transitionRuleMonthValue)
.with(transitionRule.getLocalTime());
Month month = ldt.getMonth();
} while ((ldt = ldt.plus(Period.ofWeeks(1))).getMonth() == month);
Integer dayOfMonth = allDaysOfWeek.ceiling(transitionRule.getDayOfMonthIndicator());
if (dayOfMonth == null) {
dayOfMonth = allDaysOfWeek.last();
TzOffsetFrom offsetFrom = new TzOffsetFrom(transitionRule.getOffsetBefore());
TzOffsetTo offsetTo = new TzOffsetTo(transitionRule.getOffsetAfter());
RRule rrule = new RRule(rruleText);
Observance observance = (transitionRule.getOffsetAfter().getTotalSeconds() > rawTimeZoneOffsetInSeconds) ? new Daylight() : new Standard();
observance.getProperties().add(new DtStart(startDate.withMonth(transitionRule.getMonth().getValue())
.withDayOfMonth(transitionRule.getDayOfMonthIndicator())
.with(transitionRule.getDayOfWeek()).format(DateTimeFormatter.ofPattern(DATE_TIME_TPL))));
代码示例来源:origin: bluestreak01/questdb
ZoneOffsetTransitionRule zr = lastRules[i];
TransitionRule tr = new TransitionRule();
tr.offsetBefore = zr.getOffsetBefore().getTotalSeconds();
tr.offsetAfter = zr.getOffsetAfter().getTotalSeconds();
tr.standardOffset = zr.getStandardOffset().getTotalSeconds();
tr.dow = zr.getDayOfWeek() == null ? -1 : zr.getDayOfWeek().getValue();
tr.dom = zr.getDayOfMonthIndicator();
tr.month = zr.getMonth().getValue();
tr.midnightEOD = zr.isMidnightEndOfDay();
tr.hour = zr.getLocalTime().getHour();
tr.minute = zr.getLocalTime().getMinute();
tr.second = zr.getLocalTime().getSecond();
switch (zr.getTimeDefinition()) {
case UTC:
tr.timeDef = TransitionRule.UTC;
代码示例来源:origin: ical4j/ical4j
int transitionRuleMonthValue = transitionRule.getMonth().getValue();
DayOfWeek transitionRuleDayOfWeek = transitionRule.getDayOfWeek();
LocalDateTime ldt = LocalDateTime.now(zoneId)
.with(TemporalAdjusters.firstInMonth(transitionRuleDayOfWeek))
.withMonth(transitionRuleMonthValue)
.with(transitionRule.getLocalTime());
Month month = ldt.getMonth();
} while ((ldt = ldt.plus(Period.ofWeeks(1))).getMonth() == month);
Integer dayOfMonth = allDaysOfWeek.ceiling(transitionRule.getDayOfMonthIndicator());
if (dayOfMonth == null) {
dayOfMonth = allDaysOfWeek.last();
TzOffsetFrom offsetFrom = new TzOffsetFrom(transitionRule.getOffsetBefore());
TzOffsetTo offsetTo = new TzOffsetTo(transitionRule.getOffsetAfter());
RRule rrule = new RRule(rruleText);
Observance observance = (transitionRule.getOffsetAfter().getTotalSeconds() > rawTimeZoneOffsetInSeconds) ? new Daylight() : new Standard();
observance.getProperties().add(new DtStart(startDate.withMonth(transitionRule.getMonth().getValue())
.withDayOfMonth(transitionRule.getDayOfMonthIndicator())
.with(transitionRule.getDayOfWeek()).format(DateTimeFormatter.ofPattern(DATE_TIME_TPL))));
代码示例来源:origin: net.time4j/time4j-olson
DaylightSavingRule rule;
int dom = zotr.getDayOfMonthIndicator(); // -28 bis +31 (ohne 0)
DayOfWeek dayOfWeek = zotr.getDayOfWeek();
Month month = Month.valueOf(zotr.getMonth().getValue());
zotr.isMidnightEndOfDay()
? PlainTime.midnightAtEndOfDay()
: TemporalType.LOCAL_TIME.translate(zotr.getLocalTime()));
switch (zotr.getTimeDefinition()) {
case STANDARD:
indicator = OffsetIndicator.STANDARD_TIME;
break;
default:
throw new UnsupportedOperationException(zotr.getTimeDefinition().name());
int dst = (zotr.getOffsetAfter().getTotalSeconds() - zotr.getStandardOffset().getTotalSeconds());
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Reads the state from the stream.
*
* @param in the input stream, not null
* @return the created object, not null
* @throws IOException if an error occurs
*/
static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException {
int data = in.readInt();
Month month = Month.of(data >>> 28);
int dom = ((data & (63 << 22)) >>> 22) - 32;
int dowByte = (data & (7 << 19)) >>> 19;
DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte);
int timeByte = (data & (31 << 14)) >>> 14;
TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12];
int stdByte = (data & (255 << 4)) >>> 4;
int beforeByte = (data & (3 << 2)) >>> 2;
int afterByte = (data & 3);
LocalTime time = (timeByte == 31 ? LocalTime.ofSecondOfDay(in.readInt()) : LocalTime.of(timeByte % 24, 0));
ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900));
ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800));
ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800));
return ZoneOffsetTransitionRule.of(month, dom, dow, time, timeByte == 24, defn, std, before, after);
}
内容来源于网络,如有侵权,请联系作者删除!