duration java

持续时间类plusDays()方法 (Duration Class plusDays() method)

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

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

  • plusDays() method is used to add the given duration in days to this Duration and return the Duration.

    plusDays()方法用于将以天为单位的给定持续时间添加到此Duration中,并返回Duration。

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

    plusDays()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名访问该方法,则会收到错误消息。

  • plusDays() method may throw an exception at the time of performing addition.

    plusDays()方法在执行加法时可能会引发异常。

    ArithmeticException: This exception may throw when the calculated results exceed the length of this Duration.

    ArithmeticException :当计算结果超过此Duration的长度时,可能引发此异常。

Syntax:

句法:

    public Duration plusDays(long day_val);

Parameter(s):

参数:

  • long day_val – represents the day value to add to this Duration.

    long day_val –表示要添加到此工期的天数。

Return value:

返回值:

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

此方法的返回类型为Duration ,它返回的Duration包含将给定天数添加到此Duration中的值。

Example:

例:

// Java program to demonstrate the example
// of plusDays(long day_val) method of Duration
import java.time.*;
public class PlusDaysOfDuration {public static void main(String args[]) {long days = 2;
// Instantiates two Duration objects
Duration du1 = Duration.ofDays(3);
Duration du2 = Duration.parse("P2DT20M");
// Display du1, du2
System.out.println("du1: " + du1);
System.out.println("du2: " + du2);
System.out.println("days to add: " + days);
System.out.println();
// adds the given duration in days with this
// Duration du1 and returns the Duration
// i.e. here we are adding the given 2 days
// with this du1 that holds the value of 3 days
// i.e.( 72 hrs + 48 hrs = 120 hrs )
Duration plus_val = du1.plusDays(days);
// Display plus_val
System.out.println("du1.plusDays(days): " + plus_val);
// adds the given duration in days with this
// Duration du2 and returns the Duration
// i.e. here we are adding the given 2 days
// with this du2 that holds the value of 2D:20M
// i.e.( 48 hrs + 48 hrs = 96 hrs )
plus_val = du2.plusDays(days);
// Display plus_val
System.out.println("du2.plusDays(days): " + plus_val);
}
}

Output

输出量

du1: PT72H
du2: PT48H20M
days to add: 2du1.plusDays(days): PT120H
du2.plusDays(days): PT96H20M

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

duration java

duration java_Java Duration类| plusDays()方法与示例相关推荐

  1. getenv java_Java System类getenv()方法及示例

    系统类getenv()方法getenv()方法在java.lang包中可用. getenv()方法用于返回键值对中当前环境变量的不可修改Map. 我们将看到什么是环境变量?环境变量是系统相关的外部命名 ...

  2. duration java_Java Duration类| 带示例的get()方法

    duration java 持续时间类get()方法 (Duration Class get() method) get() method is available in java.time pack ...

  3. duration java_Java Duration类| withSeconds()方法与示例

    duration java 持续时间类withSeconds()方法 (Duration Class withSeconds() method) withSeconds() method is ava ...

  4. duration java_Java Duration类| minusMinutes()方法与示例

    duration java 持续时间类minusMinutes()方法 (Duration Class minusMinutes() method) minusMinutes() method is ...

  5. duration java_Java Duration类| minusMillis()方法与示例

    duration java 持续时间类minusMillis()方法 (Duration Class minusMillis() method) minusMillis() method is ava ...

  6. duration java_Java Duration类| 带示例的getUnits()方法

    duration java 持续时间类getUnits()方法 (Duration Class getUnits() method) getUnits() method is available in ...

  7. duration java_Java Duration类| 带示例的dividBy()方法

    duration java 持续时间类divideBy()方法 (Duration Class dividedBy() method) dividedBy() method is available ...

  8. duration java_Java Duration类| 带示例的multipliedBy()方法

    duration java 持续时间类multipliedBy()方法 (Duration Class multipliedBy() method) multipliedBy() method is ...

  9. duration java_Java Duration类| toNanos()方法与示例

    duration java Duration Class toNanos()方法 (Duration Class toNanos() method) toNanos() method is avail ...

最新文章

  1. mysql 5.5 编译参数_Mysql 5.5 编译参数
  2. 报名 | AI TIME 6 论道机器翻译——离我们还有多远?
  3. svn 服务器在生产环境中的搭建
  4. java web 项目在tomcat上显示空白页的解决
  5. java-Calendar类
  6. Windows 自动登陆的简单方法
  7. linux火狐打不开网页视频下载,win10下火狐浏览器无法打开网页视频的解决方法...
  8. 在自定义Java 9映像上运行Eclipse Neon
  9. AKI-H8串口通信
  10. 致 Python 初学者们!
  11. Android之使用AlertDialog.Builder类创建带列表的对话框和带自己所布局视图的对话框
  12. 1.1zookeeper简介
  13. Java的基本数据类型与转换
  14. [置顶] 提高生产力:开源Java工具包Jodd(Java的”瑞士军刀”)
  15. 二自由度云台扫描算法_基于二维压电透射式微扫描器的红外超分辨率成像|压电扫描台...
  16. 前端接收后端导出的excel乱码、打开excel格式或文件扩展名无效等问题
  17. lombok报错Ambiguous method call. Both
  18. 卖高价的洋水果是个好榜样
  19. ElasticSearch—冷热(hotwarm)架构部署
  20. 快播王欣:我所失去的一切,都要靠区块链双倍奉还!

热门文章

  1. 设置密码命名是什么linux,orapwd 工具建立密码文件遵守的命名方法
  2. pil python 安装_20行Python代码给微信头像戴帽子
  3. html中css二级联动,html二级联动学习笔记
  4. h5页面禁止复制_H5移动端页面禁止复制技巧
  5. (2021) 22 [持久化] 1-Bit的存储
  6. 谷歌浏览器中文版_中国科学家设计超薄指尖传感器,厚度不到A4纸五分之一 / 谷歌发布地图时光机:百年前,你家街道啥样?/ AI看图说话首超人类...
  7. MySQL不走联合索引_mysql group by 多列优化思路?为什么不走联合索引?
  8. python人脸识别源码_Python 抖音机器人,让你找到漂亮小姐姐
  9. docker mysql 生产环境_如何部署Docker MySQL生产环境?
  10. 通过Flume简单实现Kafka与Hive对接(Json格式)