gpt4 book ai didi

org.threeten.bp.ZoneOffset.getId()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 20:01:31 26 4
gpt4 key购买 nike

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

ZoneOffset.getId介绍

[英]Gets the normalized zone offset ID.

The ID is minor variation to the standard ISO-8601 formatted string for the offset. There are three formats:

  • Z - for UTC (ISO-8601)
  • +hh:mm or -hh:mm - if the seconds are zero (ISO-8601)
  • +hh:mm:ss or -hh:mm:ss - if the seconds are non-zero (not ISO-8601)
    [中]获取规范化区域偏移ID。
    ID是偏移量标准ISO-8601格式字符串的微小变化。有三种格式:
    *Z-适用于UTC(ISO-8601)
    *+hh:mm或-hh:mm-如果秒为零(ISO-8601)
    *+hh:mm:ss或-hh:mm:ss-如果秒数不为零(非ISO-8601)

代码示例

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Obtains an instance of {@code ZoneOffset} specifying the total offset in seconds
 * <p>
 * The offset must be in the range {@code -18:00} to {@code +18:00}, which corresponds to -64800 to +64800.
 *
 * @param totalSeconds  the total time-zone offset in seconds, from -64800 to +64800
 * @return the ZoneOffset, not null
 * @throws DateTimeException if the offset is not in the required range
 */
public static ZoneOffset ofTotalSeconds(int totalSeconds) {
  if (Math.abs(totalSeconds) > MAX_SECONDS) {
    throw new DateTimeException("Zone offset not in valid range: -18:00 to +18:00");
  }
  if (totalSeconds % (15 * SECONDS_PER_MINUTE) == 0) {
    Integer totalSecs = totalSeconds;
    ZoneOffset result = SECONDS_CACHE.get(totalSecs);
    if (result == null) {
      result = new ZoneOffset(totalSeconds);
      SECONDS_CACHE.putIfAbsent(totalSecs, result);
      result = SECONDS_CACHE.get(totalSecs);
      ID_CACHE.putIfAbsent(result.getId(), result);
    }
    return result;
  } else {
    return new ZoneOffset(totalSeconds);
  }
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Obtains an instance of {@code ZoneOffset} specifying the total offset in seconds
 * <p>
 * The offset must be in the range {@code -18:00} to {@code +18:00}, which corresponds to -64800 to +64800.
 *
 * @param totalSeconds  the total time-zone offset in seconds, from -64800 to +64800
 * @return the ZoneOffset, not null
 * @throws DateTimeException if the offset is not in the required range
 */
public static ZoneOffset ofTotalSeconds(int totalSeconds) {
  if (Math.abs(totalSeconds) > MAX_SECONDS) {
    throw new DateTimeException("Zone offset not in valid range: -18:00 to +18:00");
  }
  if (totalSeconds % (15 * SECONDS_PER_MINUTE) == 0) {
    Integer totalSecs = totalSeconds;
    ZoneOffset result = SECONDS_CACHE.get(totalSecs);
    if (result == null) {
      result = new ZoneOffset(totalSeconds);
      SECONDS_CACHE.putIfAbsent(totalSecs, result);
      result = SECONDS_CACHE.get(totalSecs);
      ID_CACHE.putIfAbsent(result.getId(), result);
    }
    return result;
  } else {
    return new ZoneOffset(totalSeconds);
  }
}

代码示例来源:origin: ngs-doo/dsl-json

private static void writeTimezone(final int position, final OffsetDateTime dt, final JsonWriter sw) {
  final ZoneOffset zone = dt.getOffset();
  sw.advance(position);
  sw.writeAscii(zone.getId());
  sw.writeByte(JsonWriter.QUOTE);
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * 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: ThreeTen/threetenbp

/**
 * 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: ThreeTen/threetenbp

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: org.threeten/threetenbp

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: ThreeTen/threetenbp

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: org.threeten/threetenbp

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

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