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

duration java

持续时间Class ofDays()方法 (Duration Class ofDays() method)

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

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

  • ofDays() method is used to represent the given number of days in this Duration.

    ofDays()方法用于表示此Duration中给定的天数。

  • ofDays() 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.

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

  • ofDays() method may throw an exception at the time of representing days.

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

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

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

Syntax:

句法:

    public static Duration ofDays(long day_val);

Parameter(s):

参数:

  • long day_val – represents the number of days in value.

    long day_val –表示值的天数。

Return value:

返回值:

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

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

Example:

例:

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

Output

输出量

Duration.ofDays(3): PT72H

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

duration java

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

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

相关文章

面试官:怎么解决MySQL中的死锁问题?

咱们使用 MySQL 大概率上都会遇到死锁问题,这实在是个令人非常头痛的问题。本文将会对死锁进行相应介绍,对常见的死锁案例进行相关分析与探讨,以及如何去尽可能避免死锁给出一些建议。话不多说,开整!什么是死锁死锁是并…

java的equals方法_Java Duration类| 带示例的equals()方法

java的equals方法持续时间类equals()方法 (Duration Class equals() method) equals() method is available in java.time package. equals()方法在java.time包中可用。 equals() method is used to identifies whether this Duration and the given object are equal or not. …

ubuntu双系统导致进windows花屏

2019独角兽企业重金招聘Python工程师标准>>> 5600U的集成显卡,装了ubuntu的双系统,居然导致进win7的时候花屏,度娘狗哥都不得求解 网上很多解决方法都说在启动时加上nomodeset,发现对ubuntu15没用,且失去了…

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

stl resize函数C vector :: resize()函数 (C vector::resize() function) vector::resize() is a library function of "vector" header, it is used to resize the vector, it accepts the updated number of elements and a default value (optional) and resizes…

工作总结:日志打印的15个建议

前言 日志是快速定位问题的好帮手,是撕逼和甩锅的利器!打印好日志非常重要。今天我们来聊聊日志打印的15个好建议~1. 选择恰当的日志级别 常见的日志级别有5种,分别是error、warn、info、debug、trace。日常开发中,我们需要选择恰…

MFC属性页对话框

属性页对话框 分类 分页和引导 类 CPropertyPage-父亲CDialog类别,所谓的属性页或网页对话框。 CPropertySheet-父类是CWnd,称为属性表单。 一个完整的属性页对话框由一个属性表单多个属性页组成。属性页嵌套在属性表单内。 标签式属性页的创建步骤&…

vector cbegin_vector :: cbegin()函数以及C ++ STL中的示例

vector cbeginC vector :: cbegin()函数 (C vector::cbegin() function) vector::cbegin() is a library function of "vector" header, it is used to get the const iterator pointing to the first element of the vector. vector :: cbegin()是“ vector”头文件…

面试官:ConcurrentHashMap为什么放弃了分段锁?

今天我们来讨论一下一个比较经典的面试题就是 ConcurrentHashMap 为什么放弃使用了分段锁,这个面试题阿粉相信很多人肯定觉得有点头疼,因为很少有人在开发中去研究这块的内容,今天阿粉就来给大家讲一下这个 ConcurrentHashMap 为什么在 JDK8 …

C语言函数指针的应用——自制谐波分析软件

文章目录函数指针简介格式介绍颜色头文件计算机仿真使用说明完整代码部分效果图函数指针简介 如果在一个大型C语言程序中要反复调用函数,而调用的函数又不明确时,函数指针就是一个非常有用的东西。如果你的函数体内可以传递不同的函数,那就非…

PHP5.5四种序列化性能对比

2019独角兽企业重金招聘Python工程师标准>>> 结论: 1、小数组用msgpack,无论空间和性能都最好 2、大数组,考虑空间用igbinary,考虑性能用msgpack json_encode,serialize,igbinary,msgpack四种序列化方式&am…

多线程循环输出abcc++_C ++循环| 查找输出程序| 套装2

多线程循环输出abccProgram 1: 程序1&#xff1a; #include<iostream>using namespace std;int main(){ for(;;){cout<<"Hello ";}return 0;}Output: 输出&#xff1a; Hello Hello .... Infinite loopExplanation: 说明&#xff1a; In the above co…

MyBatis Plus 批量数据插入功能,yyds!

作者 | 王磊来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone最近 Review 小伙伴代码的时候&#xff0c;发现了一个小小的问题&#xff0c;小伙伴竟然在 for 循环中进行了 insert &#xff08;插入&a…

C语言打印彩色字符——以(枚举法+字符串查找)为例展示

文章目录C语言颜色头文件——自制非常简单的调用函数实战演练——一个基础的枚举变量小程序牛刀小试——查找字符小程序C语言颜色头文件——自制非常简单的调用函数 显然&#xff0c;C语言是不会提供打印彩色字符的标准函数&#xff0c;而我们有时候为了强调C语言打印的部分字…

人工智能ai 学习_学习代理| 人工智能

人工智能ai 学习Learning is an important part of human behavior. It is the first step in the development phase of any human. When the concept of Artificial Intelligence was proposed, the main approach of the developers was to build a system which could reac…

sql server中同时执行select和update语句死锁问题

原始出处 http://oecpby.blog.51cto.com/2203338/457054 最近在项目中使用SqlServer的时候发现在高并发情况下&#xff0c;频繁更新和频繁查询引发死锁。通常我们知道如果两个事务同时对一个表进行插入或修改数据&#xff0c;会发生在请求对表的X锁时&#xff0c;已经被对方持有…

再见 Spring Task,这个定时任务框架真香!

最近有朋友问到定时任务相关的问题。于是&#xff0c;我简单写了一篇文章总结一下定时任务的一些概念以及一些常见的定时任务技术选型。希望能对小伙伴们有帮助&#xff01;个人能力有限。如果文章有任何需要补充/完善/修改的地方&#xff0c;欢迎在评论区指出&#xff0c;共同…

C语言实现动画控制

文章目录原材料说明一场革命原材料 下载原材料网址: https://www.easyx.cn/downloads/ 下载easyx2014冬至版&#xff0c;将lib文件放在编译器默认的lib文件夹&#xff0c;h头文件放在编译器默认的include文件夹即可 说明 C语言可以用系统内部的定时函数sleep和usleep定时(需…

mcq 队列_MCQ | 8086微处理器中的寻址模式

mcq 队列Question 1: 问题1&#xff1a; You are given the following instruction: ADD AX , [1024] You are provided the following data: DS 3423H ; SS 1234H ; CS 4567H Find the effective address location for the given instruction. 您得到以下指示&#xff1a;…

聊聊redis分布式锁的8大坑

前言在分布式系统中&#xff0c;由于redis分布式锁相对于更简单和高效&#xff0c;成为了分布式锁的首先&#xff0c;被我们用到了很多实际业务场景当中。但不是说用了redis分布式锁&#xff0c;就可以高枕无忧了&#xff0c;如果没有用好或者用对&#xff0c;也会引来一些意想…

python 唯一元素_检查所有元素在Python中是否唯一

python 唯一元素Here, we are implementing a python program to check whether all elements of a list are unique or not? 在这里&#xff0c;我们正在实现一个python程序来检查列表的所有元素是否唯一&#xff1f; Its very simple to check, by following two steps 按…