gpt4 book ai didi

java.time.ZoneOffset.getRules()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 12:58:40 24 4
gpt4 key购买 nike

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

ZoneOffset.getRules介绍

[英]Gets the associated time-zone rules.

The rules will always return this offset when queried. The implementation class is immutable, thread-safe and serializable.
[中]获取关联的时区规则。
查询时,规则将始终返回此偏移量。实现类是不可变的、线程安全的和可序列化的。

代码示例

代码示例来源:origin: com.jtransc/jtransc-rt

public static ZoneRules of(ZoneOffset offset) {
  return offset.getRules();
}

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Obtains an instance of {@code ZoneId} from an identifier.
 *
 * @param zoneId  the time-zone ID, not null
 * @param checkAvailable  whether to check if the zone ID is available
 * @return the zone ID, not null
 * @throws DateTimeException if the ID format is invalid
 * @throws DateTimeException if checking availability and the ID cannot be found
 */
static ZoneRegion ofId(String zoneId, boolean checkAvailable) {
  Jdk8Methods.requireNonNull(zoneId, "zoneId");
  if (zoneId.length() < 2 || PATTERN.matcher(zoneId).matches() == false) {
    throw new DateTimeException("Invalid ID for region-based ZoneId, invalid format: " + zoneId);
  }
  ZoneRules rules = null;
  try {
    // always attempt load for better behavior after deserialization
    rules = ZoneRulesProvider.getRules(zoneId, true);
  } catch (ZoneRulesException ex) {
    // special case as removed from data file
    if (zoneId.equals("GMT0")) {
      rules = ZoneOffset.UTC.getRules();
    } else if (checkAvailable) {
      throw ex;
    }
  }
  return new ZoneRegion(zoneId, rules);
}

代码示例来源:origin: com.github.seratch/java-time-backport

return new ZoneRegion(zoneId, ZoneOffset.UTC.getRules());
ZoneOffset offset = ZoneOffset.of(zoneId.substring(3));
if (offset.getTotalSeconds() == 0) {
  return new ZoneRegion(zoneId.substring(0, 3), offset.getRules());
return new ZoneRegion(zoneId.substring(0, 3) + offset.getId(), offset.getRules());
  return new ZoneRegion("UT", offset.getRules());
return new ZoneRegion("UT" + offset.getId(), offset.getRules());

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Obtains an instance of {@code ZoneId} wrapping an offset.
 * <p>
 * If the prefix is "GMT", "UTC", or "UT" a {@code ZoneId}
 * with the prefix and the non-zero offset is returned.
 * If the prefix is empty {@code ""} the {@code ZoneOffset} is returned.
 *
 * @param prefix  the time-zone ID, not null
 * @param offset  the offset, not null
 * @return the zone ID, not null
 * @throws IllegalArgumentException if the prefix is not one of
 *     "GMT", "UTC", or "UT", or ""
 */
public static ZoneId ofOffset(String prefix, ZoneOffset offset) {
  Jdk8Methods.requireNonNull(prefix, "prefix");
  Jdk8Methods.requireNonNull(offset, "offset");
  if (prefix.length() == 0) {
    return offset;
  }
  if (prefix.equals("GMT") || prefix.equals("UTC") || prefix.equals("UT")) {
    if (offset.getTotalSeconds() == 0) {
      return new ZoneRegion(prefix, offset.getRules());
    }
    return new ZoneRegion(prefix + offset.getId(), offset.getRules());
  }
  throw new IllegalArgumentException("Invalid prefix, must be GMT, UTC or UT: " + prefix);
}

代码示例来源:origin: com.github.seratch/java-time-backport

return new ZoneRegion(zoneId, ZoneOffset.UTC.getRules());
ZoneOffset offset = ZoneOffset.of(zoneId.substring(3));
if (offset.getTotalSeconds() == 0) {
  return new ZoneRegion(zoneId.substring(0, 3), offset.getRules());
return new ZoneRegion(zoneId.substring(0, 3) + offset.getId(), offset.getRules());
  return new ZoneRegion("UT", offset.getRules());
return new ZoneRegion("UT" + offset.getId(), offset.getRules());

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