duration java_Java Duration类| ofHours()方法与示例

duration java

Duration Class of Hours()方法 (Duration Class ofHours() method)

  • ofHours() method is available in java.time package.

    ofHours()方法在java.time包中可用。

  • ofHours() method is used to represent the given hours in this Duration.

    ofHours()方法用于表示此Duration中的给定小时数。

  • ofHours() method is a static method, it is accessible with the class name and if we try to access the method with the class object then we will not get an error.

    ofHours()方法是一个静态方法,可以使用类名进行访问,如果尝试使用类对象访问该方法,则不会收到错误。

  • ofHours() method may throw an exception at the time of representing hours.

    ofHours()方法在表示小时数时可能会引发异常。

    ArithmeticException: This exception may throw when the given hours' value exceeds the length of this Duration.

    ArithmeticException :当给定小时数的值超过此Duration的长度时,可能引发此异常。

Syntax:

句法:

    public static Duration ofHours(long hrs_val);

Parameter(s):

参数:

  • long hrs_val – represents the number of hours in value.

    long hrs_val –表示值的小时数。

Return value:

返回值:

The return type of this method is Duration, it returns the Duration that holds the value of the given hours.

此方法的返回类型为Duration ,它返回保存给定小时数的Duration。

Example:

例:

// Java program to demonstrate the example 
// of ofHours(long hrs_val) method of Duration
import java.time.*;
public class OfHoursOfDuration {
public static void main(String args[]) {
long hrs_val = 3;
// returns the Duration that holds the value of the given
// argument i.e. here we are representing
// 3 hrs (3H) in this Duration du
Duration du = Duration.ofHours(hrs_val);
// Display du
System.out.println("Duration.ofHours(3): " + du);
}
}

Output

输出量

Duration.ofHours(3): PT3H

翻译自: https://www.includehelp.com/java/duration-ofhours-method-with-example.aspx

duration java

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541548.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

sumo的简单应用_sumo快速运行简单仿真实例详细教程

本文旨在让大家快速的了解sumo,并给出运行一个简单的sumo的例子的教程,进而了解基本sumo工程的架构,使大家对该软件产生兴趣并持续学习下去,刚开始学习仿真的确枯燥,项目“跑起来”才是大家学习下去的动力,…

stl vector 函数_vector :: crbegin()函数,以及C ++ STL中的示例

stl vector 函数C vector :: crbegin()函数 (C vector::crbegin() function) vector::crbegin() is a library function of "vector" header, it is used to get the last element of a vector using const_reverse_iterator, it returns a const reverse iterator …

ReactNative学习笔记(二)Flex布局

flexDirection 决定主轴方向 column:垂直方向为主轴row:水平方向为主轴justifyContent 决定主轴元素排列方式 flex-startflex-endcenterspace-betweenspace-aroundalignItems 决定侧轴元素排列方向 flex-startflex-endcenterbaselinestretch

cad导出 dxf后中文不显示_CAD快速看图 for Mac

CAD快速看图 for Mac是一款非常小巧、快速、方便的DWG看图工具,CAD快速看图 Mac版可脱离AutoCAD最快速、最方便浏览DWG和DXF图纸,支持二维或三维图纸,支持高清、多文件和云字体,非常实用的一款CAD看图软件,CAD快速看图…

scala运算符_Scala的所有符号运算符是什么意思?

scala运算符Scala的符号运算符 (Scalas symbolic operators) The symbolic operators in Scala are symbols that have a specific task that they perform when called in a Scala program. Scala library defines a lot of symbols that can be used while programming in Sc…

关于java.util.ConcurrentModificationException和remove倒数第二个元素

2019独角兽企业重金招聘Python工程师标准>>> 首先是两段代码的执行结果&#xff1a; 代码一&#xff1a; public class TestListRemove {public static void main(String[] args) {List<Integer> list new ArrayList<Integer>();list.add(1);list.add(…

linux 操作mysql 数据库命令_Linux 操作数据库命令

一、连接数据库格式&#xff1a; mysql -h主机地址 -u用户名 &#xff0d;p用户密码mysql -hlocalhost -uroot -p123注&#xff1a;-h,-u,-p 后面不加空格&#xff0c;进入数据库操作后每个命令结尾都需加“&#xff1b;(分号)”二、退出MYSQL命令exit (回车)三、显示所有数据库…

fragment和Activity同时操作UI引起的延迟、卡顿

最近项目中遇到一个问题&#xff0c;app首页的Activity中由若干个Fragment页面组成&#xff0c;其中一个fragment页面是由一个GridView和ListView组成的列表&#xff0c;如果列表中数据量过大的时候&#xff0c;在请求数据的时候点击页面上的其他按钮会无响应&#xff0c;直到该…

怎么删除mysql的压缩包_压缩包版mysql怎么卸载

MySQL是一个小巧玲珑但功能强大的数据库&#xff0c;目前十分流行。但是官网给出的安装包有两种格式&#xff0c;一个是msi格式&#xff0c;一个是zip格式的。那么压缩版mysql要怎么卸载&#xff1f;下面本篇文章就来大家介绍一下&#xff0c;希望对你们有所帮助。卸载压缩包版…

obj.val 非数组_在Ruby中使用Array.new(size,obj)创建数组

obj.val 非数组In the previous article, we have learnt how we can declare an Array class instance with the help of Array.[](*args) method? You can also notice that in the program codes written to demonstrate all those methods are having Array instances dec…

julia在mac环境变量_在Julia中找到值/变量的类型

julia在mac环境变量To find the type of a variable/value, we use the typeof() function – it accepts a parameter whose type to be found and returns its data type. 为了找到变量/值的类型&#xff0c;我们使用typeof()函数-它接受要查找其类型的参数并返回其数据类型。…

lambda表达式之进化

前言在C#我们可以自定义委托&#xff0c;但是C#为什么还要内置泛型委托呢&#xff1f;因为我们常常要使用委托&#xff0c;如果系统内置了一些你可能会用到的委托&#xff0c;那么就省去了定义委托&#xff0c;然后实例化委托的步骤&#xff0c;这样一来既使代码看起来简洁而干…

mysql返回行数_如何计算MySQL查询返回的行数?

How can I count the number of rows that a MySQL query returned?解决方案Getting total rows in a query result...You could just iterate the result and count them. You dont say what language or client library you are using, but the API does provide a mysql_nu…

md5不是对称密码算法_密码学中的消息摘要算法5(MD5)

md5不是对称密码算法In cryptography, MD5 (Message-Digest algorithm 5) is a mainly used cryptographic hash function with a 128-bit hash value. As we use in an Internet standard (RFC 1321), MD5 has been employed or developed in a more variety of security appl…

Windows 7 SID 修改

在安裝Windows系統時會產生一個獨一無二的SID (Security ID)&#xff0c;它用來識別每一部主機&#xff0c;若在同一個區域網路內有兩部相同SID的主機&#xff0c;會出現警告訊息。一般而言&#xff0c;每次安裝時的SID不可能會發生重複&#xff0c;但若是使用TrueImage或Ghost…

discuz mysql 类_discuz7 phpMysql操作类

MySql数据库连接类&#xff0c;大家可以看下网上老手们用的什么方法&#xff0c;大家可以直接拿来用&#xff0c;但前提是大家能熟练的掌握的基础上&#xff0c;这样才能有所进步。/** MySql数据库连接类* mysql.class.php 2009.04.15 by Hackbaby*/class dbstuff {var $versio…

1 并发模型

并发系统可以采用多种并发编程模型来实现。并发模型指定了系统中的线程如何通过协作来完成分配给它们的作业。不同的并发模型采用不同的方式拆分作业&#xff0c;同时线程间的协作和交互方式也不相同。这篇并发模型教程将会较深入地介绍目前&#xff08;2015年&#xff0c;本文…

Java String compareTo()方法与示例

字符串compareTo()方法 (String compareTo() Method) compareTo() is a String method in Java and it is used to compare two strings (case-sensitive). compareTo()是Java中的String方法&#xff0c;用于比较两个字符串(区分大小写)。 If both strings are equal – it r…

nginx mysql 查询系统_nginx/mysql查看内存占用

查看每个php-fpm平均占用系统内存,也适用看nginx/mysqld等,把php-fpm换成mysqldps --no-headers -o "rss,cmd" -C php-fpm | awk { sum$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }查看占用内存[rootcentos69 ~]# ps -ylC php-fpm --sort:r…

linux用户及权限详解(20170425)

计算机资源权限用户用户&#xff0c;容器&#xff0c;关联权限&#xff1a;用户组&#xff0c;方便的指派权限用户&#xff1a;标示符用户组&#xff1a;标示符r 、w、x&#xff1a;1、2、4对于文件r:可读&#xff0c;可以使用类似cat等命令查看文件内容w&#xff1a;可写&…