gpt4 book ai didi

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

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

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

ZoneOffset.getLong介绍

[英]Gets the value of the specified field from this offset as a long.

This queries this offset for the value for the specified field. If it is not possible to return the value, because the field is not supported or for some other reason, an exception is thrown.

If the field is a ChronoField then the query is implemented here. The OFFSET_SECONDS field returns the value of the offset. All other ChronoField instances will throw a DateTimeException.

If the field is not a ChronoField, then the result of this method is obtained by invoking TemporalField.getFrom(TemporalAccessor)passing this as the argument. Whether the value can be obtained, and what the value represents, is determined by the field.
[中]从该偏移量中获取指定字段的值作为长字符串。
这将查询该偏移量以获取指定字段的值。如果由于字段不受支持或其他原因而无法返回值,则会引发异常。
如果该字段是一个ChronoField,则在此处实现查询。OFFSET_SECONDS字段返回偏移量的值。所有其他ChronoField实例将抛出DateTimeException。
如果该字段不是ChronoField,则通过调用TemporalField获得该方法的结果。getFrom(临时助理)将此作为参数传递。是否可以获得该值,以及该值代表什么,取决于字段。

代码示例

代码示例来源:origin: org.codehaus.groovy/groovy-datetime

/**
 * Supports the getAt operator; equivalent to calling the
 * {@link java.time.ZoneOffset#getLong(java.time.temporal.TemporalField)} method.
 *
 * @param self  a ZoneOffset
 * @param field a TemporalField
 * @return the ZoneOffset's field value
 * @since 2.5.0
 */
public static long getAt(final ZoneOffset self, TemporalField field) {
  return self.getLong(field);
}

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

throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
return range(field).checkValidIntValue(getLong(field), field);

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