java range类_Java即时类| range()方法与示例
java range类
即时类range()方法 (Instant Class range() method)
range() method is available in java.time package.
range()方法在java.time包中可用。
range() method is used to get the valid range of values for the given TemporalField.
range()方法用于获取给定TemporalField的有效值范围。
range() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
range()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
range() method may throw an exception at the time of returning field range.
在返回字段范围时, range()方法可能会引发异常。
- DateTimeException: This exception may throw when the given field value couldn't be generated.DateTimeException :当无法生成给定的字段值时,可能引发此异常。
- UnsupportedTemporalTypeException: This exception may throw when the given temporal field is unsupported.
- UnsupportedTemporalTypeException :如果不支持给定的时间字段,则可能引发此异常。
Syntax:
句法:
public ValueRange range(TemporalField t_field);
Parameter(s):
参数:
TemporalField t_field – represents the field of the returned values range.
TemporalField t_field –代表返回值范围的字段。
Return value:
返回值:
The return type of this method is ValueRange, it returns range of values for the given field in this Instant.
此方法的返回类型为ValueRange ,它返回此Instant中给定字段的值范围。
Example:
例:
// Java program to demonstrate the example
// of ValueRange range(TemporalField t_field)
// method of Instant
import java.time.*;
import java.time.temporal.*;
public class RangeOfInstant {public static void main(String args[]) {// Instantiates two Instant
Instant ins1 = Instant.parse("2006-04-03T05:10:15.00Z");
Instant ins2 = Instant.now();
// Display ins1,ins2
System.out.println("Instant ins1 and ins2: ");
System.out.println("ins1: " + ins1);
System.out.println("ins2: " + ins2);
System.out.println();
// Here, this method gets the valid
// range of values for the given field
// i.e. here the MICRO_OF_SECOND field
// range will be returned
ValueRange range = (ValueRange) ins1.range(ChronoField.MICRO_OF_SECOND);
// Display range
System.out.println("ins1.get(ChronoField.MICRO_OF_SECOND): " + range);
// Here, this method gets the valid
// range of values for the given field
// i.e. here the MILLI_OF_SECOND field
// range will be returned
range = (ValueRange) ins2.range(ChronoField.MILLI_OF_SECOND);
// Display range
System.out.println("ins2.get(ChronoField.MILLI_OF_SECOND): " + range);
// Here, this method gets the valid
// range of values for the given field
// i.e. here the NANO_OF_SECOND field
// range will be returned
range = (ValueRange) ins2.range(ChronoField.NANO_OF_SECOND);
// Display range
System.out.println("ins2.get(ChronoField.NANO_OF_SECOND): " + range);
}
}
Output
输出量
Instant ins1 and ins2:
ins1: 2006-04-03T05:10:15Z
ins2: 2020-05-27T05:30:00.259110Zins1.get(ChronoField.MICRO_OF_SECOND): 0 - 999999
ins2.get(ChronoField.MILLI_OF_SECOND): 0 - 999
ins2.get(ChronoField.NANO_OF_SECOND): 0 - 999999999
翻译自: https://www.includehelp.com/java/instant-range-method-with-example.aspx
java range类
java range类_Java即时类| range()方法与示例相关推荐
- java 根据类名示例化类_Java即时类| EpochSecond()方法的示例
java 根据类名示例化类 EpochSecond()方法的即时类 (Instant Class ofEpochSecond() method) Syntax: 句法: public static I ...
- java 根据类名示例化类_Java即时类| from()方法与示例
java 根据类名示例化类 即时类from()方法 (Instant Class from() method) from() method is available in java.time pack ...
- java 根据类名示例化类_Java即时类| plusMillis()方法与示例
java 根据类名示例化类 即时类plusMillis()方法 (Instant Class plusMillis() method) plusMillis() method is available ...
- java 根据类名示例化类_Java即时类| minusNanos()方法与示例
java 根据类名示例化类 即时类minusNanos()方法 (Instant Class minusNanos() method) minusNanos() method is available ...
- java 根据类名示例化类_Java即时类| getEpochSecond()方法与示例
java 根据类名示例化类 即时类getEpochSecond()方法 (Instant Class getEpochSecond() method) getEpochSecond() method ...
- java math.sin()_Java Math sin() 使用方法及示例
Java Math sin() 使用方法及示例 Java Math sin()返回指定角度的三角正弦值. sin()方法的语法为: Math.sin(double angle) sin()参数angl ...
- java sublist 用法_Java ArrayList subList() 使用方法及示例
Java ArrayList subList() 使用方法及示例 Java ArrayList subList()方法提取一部分arraylist并将其返回. subList()方法的语法为: arr ...
- java isempty用法_Java ArrayList isEmpty() 使用方法及示例
Java ArrayList isEmpty() 使用方法及示例 Java ArrayList isEmpty()方法用于检查arraylist是否为空. 该isEmpty()方法的语法为: arra ...
- java中get接口示例_Java即时类| 带示例的get()方法
java中get接口示例 即时类的get()方法 (Instant Class get() method) get() method is available in java.time package ...
最新文章
- javascript RegExp
- 谁说LINQ复杂查询不支持返回实名类型~复杂结果集中再使用复杂结果集
- 机器学习Sklearn实战——决策树算法
- QT学习:获取本机网络信息
- OpenCV—形态学运算定义与实现
- java 二维数组_Java中二维数组和异常的内容及应用
- PYTHON__关于Socket中的Select使用理解
- java泛型实例化_java基础-泛型举例详解
- Uva 10306 e-Coins
- 阻塞、非阻塞、同步、异步的区别
- Kafka集群安装部署、Kafka生产者、Kafka消费者
- charts 画折线图
- idea在编辑界面上显示多个文件
- 运动会管理系统(JAVA,JSP,SERVLET,SQLSERVER)
- web漏洞扫描器-awvs
- 1元云购网站建设,一元云购网站制作,夺宝网站定制公司,一元云购源码开发
- 荆州水文水位查询_长江水位实时查询网(长江水位公告实时查询)
- linux添加多网站,linux添加多个网站-微笑の风
- Vue 2.0 升(cai)级(keng)之旅
- GIS空间分析 栅格数据分析2 成本距离分析