gpt4 book ai didi

java.time.zone.ZoneOffsetTransitionRule类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 02:53:31 27 4
gpt4 key购买 nike

本文整理了Java中java.time.zone.ZoneOffsetTransitionRule类的一些代码示例,展示了ZoneOffsetTransitionRule类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOffsetTransitionRule类的具体详情如下:
包路径:java.time.zone.ZoneOffsetTransitionRule
类名称: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:

  • the 16th March
  • the Sunday on or after the 16th March
  • the Sunday on or before the 16th March
  • the last Sunday in February

These different rule types can be expressed and queried.

Specification for implementors

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);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com